Question checkboxlist with image

startthinking

Member
Joined
Oct 14, 2010
Messages
8
Programming Experience
3-5
hi guys i am doing a project with vb.net
it is windows application project

i need to put daynamic check boxes so i use checkboxlist but also i want to use an image beside each check box

i have an image for what acctully i need
please check the image below

27881564.jpg



please help me to do that
 
For this you can for example create a UserControl with a CheckBox and a Picturebox, then add instances of the UserControl to a FlowLayoutPanel.
 
You don't need a UserControl. The CheckBox already supports that functionality. Simply create a CheckBox, set the CheckAlign to Bottom and then set the Image property.

As for the list, simply add a FlowLayoutPanel to your form, as JohnH says, and then call its Add method and pass your newly created CheckBox. For more information, start by reading the MSDN documentation for the FlowLayoutPanel and then search for existing examples.
 
I would probably suggest not getting the checked items from the FlowLayoutPanel. I'd probably suggest storing the controls separately in a List(Of CheckBox). That would just make then a little easier to work with. You can then loop through that List to get each item and test its Checked property. More simply, you could use LINQ:
VB.NET:
Dim checkItems As CheckBox() = myList.Where(Function(cb) cb.Checked).ToArray()
 
Back
Top