By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,953 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,953 IT Pros & Developers. It's quick & easy.

Designer problem / User Control issue

P: n/a
Jim
I am having some trouble with user controls and would appreciate any input /
advice on where to go with this... :)

1. The first problem, and perhaps the root of the others, is that I have
several user controls that are inherited user controls, based on one class,
which is in turn based on System.Windows.Forms.UserControl. We'll call this
class "UserControlBase". My first problem is that UserControlBase implements
some public properties that really have no meaning at design-time. ie, their
values are based on object references that are not set at design time. When
the designer tries to render the values of these properties in the design
grid, you get an "Object Reference Not Set to an instance of an object"
error. I resolved this problem by providing the following attribute to all
of my properities of UserControlBase...

[DesignerSerializationVisibility( DesignerSerializationVisibility.Hidden)]

This keeps the designer from showing the properites in the grid. However,
when I then compile, and create a new user control based on UserControlBase
(let's call it InerheritiedUserControl), it is once again trying to obtain
values from the public properties that it inherited from UserControlBase,
thus ignoring the attribute I put on there. Is there anything I can do to
keep the designer from attempting to display or otherwise auto-generate code
for my properties of a user control?

2. Problem #2 I am going to guess is probably related to problem #1, in
that it's probably being caused by the fact that something in the deisgner is
puking over my user controls, and this screws up the rest of the environment,
as this is the first time I've ever seen this happen... Any thoughts? The
problem is that when I switch from code view to design view for one of my
inherited user controls, or any other control that has one of these inherited
user controls hosted on it, and then switch back to code view, the IDE starts
misbehaving. ie, all the blue keywords (if, else, public, etc) turn black;
the Intellisense quits working, and stuff doesn't auto-indent properly when I
type. The only way to fix it is to close and re-open the environment. This
only seems to become an issue when you do something inside the visual design
environment and then try to go back out to code. I have never run into this
before, which is why I'm guessing that it's related to the other problem I
described above.

Thanks in advance for any input on this....
Nov 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.