Groups | Blog | Home
all groups > visual studio .net general > may 2004 >

visual studio .net general : abstract base class and Visual Designer question


jason
5/27/2004 4:46:05 PM
Hi
I have a question about the visual designer not being able to edit a control based on an abstract class. When I open the derived control in the visual designer I get an error like

"The designer must create an instance of type 'namespace.class' but it cannot because the type is declared as abstract.

I do understand why it does this and I really don't need to "edit" my class in the designer, so it not a problem. However, my real question is how the designer can allow you to edit a Windows Forms controls such as the Button control when it is based on the abstract System.Windows.Forms.ButtonBase class. Does this make sense

Jaso
v-garych NO[at]SPAM online.microsoft.com
5/28/2004 6:12:51 AM
Hi Jason,

[quoted text, click to view]
class in the designer, so it not a problem. However, my real question is
how the designer can allow you to edit a Windows Forms controls such as the
Button control when it is based on the abstract
System.Windows.Forms.ButtonBase class. Does this make sense?
[quoted text, click to view]

When you Add control(such as the Button) onto a Form and modify its
properties, we only need generate code in Form.InitializeComponet method to
set properties, so it's modifying the Button object, not the Button class,
in this scenario, we create Button not ButtonBase class.

However, designing a Form(open the derived control in the visual designer)
is a special scenario, we need generate code into InitializeComponent. When
you modifying the control's properties/attributes, it is modifying the
class definition not the form object actually, so that we create the base
class of your Form ¡­.
(This is a special scenario when the control is a root component in your
designer view)


Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
jason
6/2/2004 2:16:06 PM
Thank you for the explaination

AddThis Social Bookmark Button