can't design UserControl
-
**CROSSPOSTED TO .NET FRAMEWORK FORUM** Hi all, I've got a class called RowView derived from UserControl, which is itself the parent of another class (AuthorView). RowView has a public property Data. Since RowView should never be instantiated directly (it's a pseudo-abstract class) it doesn't implement Data, it simply throws a NotSupportedException. My AuthorView class does implement Data. Now my problem is that whenever I try and 'design' AuthorView in VS .NET the designer tries to access RowView.Data, which throws an exception. So my question is, how do I stop VS .NET's designer from attempting to access Data. I've tried settig the Browsable attribute to false in RowView.Data, but it doesn't help. I can post up some code if that'll help clarify the situation. TIA, Pete
-
**CROSSPOSTED TO .NET FRAMEWORK FORUM** Hi all, I've got a class called RowView derived from UserControl, which is itself the parent of another class (AuthorView). RowView has a public property Data. Since RowView should never be instantiated directly (it's a pseudo-abstract class) it doesn't implement Data, it simply throws a NotSupportedException. My AuthorView class does implement Data. Now my problem is that whenever I try and 'design' AuthorView in VS .NET the designer tries to access RowView.Data, which throws an exception. So my question is, how do I stop VS .NET's designer from attempting to access Data. I've tried settig the Browsable attribute to false in RowView.Data, but it doesn't help. I can post up some code if that'll help clarify the situation. TIA, Pete
-
You can use the Site.DesignMode to stop VS .NET's designer from attempting to access Data.
Do you mean something along the lines of:
public property object Data
{
get
{
if( !DesignMode )
throw new NotSupportedException();
else
return null;
}
}Is that the only way to solve this problem? I don't really like the idea of having little if( !DesignMode ) lines all over my code :| But thanks for the help :)