Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2007

Tip: Looking for answers? Try searching our database.

State buttons

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 07 Jan 2007 17:46 GMT
Hi

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

Thanks

Regards
Mattias Sjögren - 07 Jan 2007 18:15 GMT
>Does vs 2005 have buttons that can have two states i.e. depressed and
>normal?

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

Mattias

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

John - 07 Jan 2007 18:36 GMT
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

> >Does vs 2005 have buttons that can have two states i.e. depressed and
>>normal?
[quoted text clipped - 3 lines]
>
> Mattias
Rad [Visual C# MVP] - 07 Jan 2007 19:55 GMT
> 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
[quoted text clipped - 3 lines]
>
> Regards

Hey John,

The width of the checkbox with an appearance of Button will adjust to fit
the checkbox text

Signature

Bits.Bytes
http://bytes.thinkersroom.com

Jay B. Harlow [MVP - Outlook] - 07 Jan 2007 22:26 GMT
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:

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

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.

Signature

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

> 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
[quoted text clipped - 11 lines]
>>
>> Mattias

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.