dynamically create chexboxes from datatable

tundeemma

New member
Joined
Mar 22, 2009
Messages
2
Programming Experience
10+
working on a winform project like to dynamically create chexboxes from a datatable rows.
see attache pics. Any help will be appreciated.
thanks
 

Attachments

  • checkbox1.gif
    checkbox1.gif
    1.8 KB · Views: 39
I'd suggest using a TableLayoutPanel to contain the CheckBoxes so that you can configure it to grow as desired. You can then simply loop through the rows of the DataTable and, for each one, create a CheckBox and add it to the TLP.
 
Add an extra column to your datatable and set it as a datatype of boolean, it will automatically place a checkbox in each displayed record.
 
Add an extra column to your datatable and set it as a datatype of boolean, it will automatically place a checkbox in each displayed record.
It sounds like you're assuming that the data is being bound to a DataGridView, which the image provided suggests is not the case.
 
jmcilhinney thanks very much for your contribution. Pls can you place a simple code on how to go by your suggestion?
For Tom, each of the checkbox is a row. I will only form 3 or 4 checkboxes on a row based on the total no of records that was returned in the dataTable. Thus the text properties of the checkboxes are the actual data from the database.
so what i want to do is to retrieve the data from the database into a datatable, instead of displying it in a datagrid i will display it as chexboxes arrange in rows and columns as the picture explained.
 
Last edited:
jmcilhinney thanks very much for your contribution. Pls can you place a simple code on how to go by your suggestion?
For Tom, each of the checkbox is a row. I will only form 3 or 4 checkboxes on a row based on the total no of records that was returned in the dataTable. Thus the text properties of the checkboxes are the actual data from the database.
so what i want to do is to retrieve the data from the database into a datatable, instead of displying it in a datagrid i will display it as chexboxes arrange in rows and columns as the picture explained.
I'm always interested in people having a go first before assuming that they can't and asking someone else to do it for them. Have you added a TableLayoutPanel to a form and played with it to see what it can do? Have you read the class documentation?
 
Back
Top