State buttons

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

Does vs 2005 have buttons that can have two states i.e. depressed and
normal?

Thanks

Regards
 
Does vs 2005 have buttons that can have two states i.e. depressed and

You can use the CheckBox control with the Appearance property set to
Button.


Mattias
 
Thanks but can't work out how to make its size to what I need. No handles to
make it bigger. Manually setting the size in properties does not work
either.

Thanks

Regards
 
Thanks but can't work out how to make its size to what I need. No handles to
make it bigger. Manually setting the size in properties does not work
either.

Thanks

Regards

Hey John,

The width of the checkbox with an appearance of Button will adjust to fit
the checkbox text
 
John,
As Rad suggests, by default the button will adjust to fit the checkbox &
text.

You can control this behavior with the AutoSize property. So to answer your
original question:

Use a Checkbox with:
Appearance = Button
AutoSize = False

Changing the FlatStyle to Flat you can use the FlatAppearance property to
control the colors used by the button. For example, a Green "toggle" button:

Me.CheckBox1.Appearance = System.Windows.Forms.Appearance.Button
Me.CheckBox1.BackColor = System.Drawing.Color.LightGreen
Me.CheckBox1.FlatAppearance.BorderColor = System.Drawing.Color.Green
Me.CheckBox1.FlatAppearance.CheckedBackColor =
System.Drawing.Color.Green
Me.CheckBox1.FlatAppearance.MouseDownBackColor =
System.Drawing.Color.DarkGreen
Me.CheckBox1.FlatAppearance.MouseOverBackColor =
System.Drawing.Color.PaleGreen
Me.CheckBox1.FlatStyle = System.Windows.Forms.FlatStyle.Flat


FWIW: A number of controls gained the AutoSize property in .NET 2.0, if a
control is not resizing for you check for this property.

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


John said:
Thanks but can't work out how to make its size to what I need. No handles
to make it bigger. Manually setting the size in properties does not work
either.

Thanks

Regards
 
Back
Top