Windows Develop Bookmark and Share   
 index > Windows Forms General > checkbox buttons - how to make one appear selected/depressed/actively/
 

checkbox buttons - how to make one appear selected/depressed/actively/

Given the following dynamic creation of buttons, how do I satisfy my end user's request to have the selected button have adepressed or pushed down appearance. There may be 64 buttons n this flowlayout panel and it has to be obvious at a glance which one is actively checked. thank you. -greg

Code Snippet

Public CameraButton As New System.Collections.Generic.List(Of CheckBox)

Private nCamerasMax As Integer

Private Sub UserControl_Initialize()

For iCamera = 0 To nCamerasMax

Dim c As New CheckBox

c.Appearance = Appearance.Button

c.Text = (iCamera + 1).ToString()

CameraButton.Add(c)

FlowLayoutPanel1.Controls.Add(c)

AddHandler c.CheckStateChanged, AddressOf Checkbox_CheckStateChanged

AddHandler c.MouseDown, AddressOf CameraButton_MouseDown

AddHandler c.MouseUp, AddressOf CameraButton_MouseUp

Next iCamera

hazz  Wednesday, August 22, 2007 11:34 PM
Use a CheckBox control with its Appearance set to Button.
nobugz  Thursday, August 23, 2007 9:34 AM

Thanks Hans. I highlighted that code in red, the button appearance.

In order to distinguish the selected button from the others I am trying something like the following;

Code Snippet

Private Sub Checkbox_CheckStateChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

Dim ckbox As CheckBox = CType(sender, CheckBox)

If ckbox.Checked Then

ckbox.FlatStyle = FlatStyle.Popup

Else

ckbox.FlatStyle = FlatStyle.System

End If

hazz  Thursday, August 23, 2007 4:01 PM
Use a CheckBox control with its Appearance set to Button.
nobugz  Thursday, August 23, 2007 9:34 AM

Thanks Hans. I highlighted that code in red, the button appearance.

In order to distinguish the selected button from the others I am trying something like the following;

Code Snippet

Private Sub Checkbox_CheckStateChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

Dim ckbox As CheckBox = CType(sender, CheckBox)

If ckbox.Checked Then

ckbox.FlatStyle = FlatStyle.Popup

Else

ckbox.FlatStyle = FlatStyle.System

End If

hazz  Thursday, August 23, 2007 4:01 PM

You can use google to search for other answers

Custom Search

More Threads

• How to create a control similar to that of option dialogs in windows
• A Simple GUI Question
• Reg-Major Changes in .Net Framework 3.0 to .Net Framework 2.0
• How to have one instance of the form? VB.net or VS 2005(VB)
• Avoiding the selection of text in a DropDown ListBox
• Accessing objects(controls) across threads...
• ComboBoxes again
• Visual studio 2005 Team System
• How to get the selected text in the current active application?
• Why can I create a web refernece but when I try to use that web referece do I get an error?