Custom Button Control

Viper

Member
Joined
Aug 27, 2004
Messages
17
Location
South Africa
Programming Experience
5-10
Hi

I've created a control that inherits from the button control. The control has one additional property called ButtonType which can be set to Ok, Cancel, New, Edit, etc. When the ButtonType property changes, the Image, Text, TextAlignment, etc. properties are changed for the control.

What happens is that when I put the control on a form and I set the ButtonType property, all the fields that are changed are then highlighted as changed and written in the Form.Designer.vb file to initialize those properties. How can I prevent this from happening?

At the moment, the following is written:
VB.NET:
        Me.DialogButton1.Location = New System.Drawing.Point(359, 133)
        Me.DialogButton1.Cursor = System.Windows.Forms.Cursors.Hand
        Me.DialogButton1.ButtonType = ButtonTypeEnum.Arrow_Next
        Me.DialogButton1.Font = New System.Drawing.Font("Tahoma", 9.0!)
        Me.DialogButton1.Image = CType(resources.GetObject("DialogButton1.Image"), System.Drawing.Image)
        Me.DialogButton1.ImageAlign = System.Drawing.ContentAlignment.MiddleRight
        Me.DialogButton1.MaximumSize = New System.Drawing.Size(90, 28)
        Me.DialogButton1.MinimumSize = New System.Drawing.Size(90, 28)
        Me.DialogButton1.Size = New System.Drawing.Size(90, 28)
        Me.DialogButton1.Text = "&Next     "
        Me.DialogButton1.TextAlign = ContentAlignment.MiddleRight
        Me.DialogButton1.TextImageRelation = TextImageRelation.TextBeforeImage
        Me.DialogButton1.Name = "DialogButton1"
'Basically most of those properties are already set when the control is created or when the ButtonType property is set. So basically all I want to appear in the form designer is:
VB.NET:
        Me.DialogButton1.Location = New System.Drawing.Point(359, 133)
        Me.DialogButton1.ButtonType = ButtonTypeEnum.Arrow_Next
        Me.DialogButton1.Name = "DialogButton1"

Any ideas how I can do this?

Regards

Wimpie
 
I don't think it would be possible with any default members of a control. The concept of designer is to load all default property for it's control. So, it would appear once you created a control.

If you make your own property, you can set its default value so it won't appear in designer with system.componentmodel.defaultvalue attribute
 
Back
Top