Hello all,
I'm working on a small problem with regard to the CheckedListBox and mapping to a data source
I have a database with three fields
'Name' - The description of the item, a string and quite short
'ID' - A unique ID, auto incremented by the database
'Active' - A 1 or a 0 to show if that item is active (this active flag is used in other queries in the application)
I also have a windows form with a Checkedlistbox called 'checkedlistbox'.
I have managed to populate a datatable and make it the datasource of the Checkedlistbox
This all displays happily. What I need to do is somehow map the 'Active' element in the dataTable to the boolean option of having a checkbox actually checked or not when it is displayed in the list.
At the moment, no matter if the datatable has 'Active' down as 1 or 0 for any row, the corrosponding item is the list is always unchecked.
Can anyone help?
I did think of simply looping around the datatable then having an if statment pick wheher the item to be added has checked or not, but as far as I can tell if I use this method I will not be able use the ValueMember and DisplayMember - am I right?
Thanks for any help guys
I'm working on a small problem with regard to the CheckedListBox and mapping to a data source
I have a database with three fields
'Name' - The description of the item, a string and quite short
'ID' - A unique ID, auto incremented by the database
'Active' - A 1 or a 0 to show if that item is active (this active flag is used in other queries in the application)
I also have a windows form with a Checkedlistbox called 'checkedlistbox'.
I have managed to populate a datatable and make it the datasource of the Checkedlistbox
VB.NET:
//myData is a populated datatable
checkedlistbox.DataSource = myData
checkedlistbox.DisplayMember = "Name"
checkedlistbox.ValueMember = "ID"
This all displays happily. What I need to do is somehow map the 'Active' element in the dataTable to the boolean option of having a checkbox actually checked or not when it is displayed in the list.
At the moment, no matter if the datatable has 'Active' down as 1 or 0 for any row, the corrosponding item is the list is always unchecked.
Can anyone help?
I did think of simply looping around the datatable then having an if statment pick wheher the item to be added has checked or not, but as far as I can tell if I use this method I will not be able use the ValueMember and DisplayMember - am I right?
Thanks for any help guys