CheckBoxes based on contents of a db table.

  • Thread starter Thread starter Mufasa
  • Start date Start date
M

Mufasa

I have a program that will allow a user to select/deselect values for a
record. On that record there are multiple check boxes which are defined in
the database. What's the easiest way to get the list of checkboxes and
display them on the screen.

Here's an example:

They want to edit a record. It loads the record. In the process it looks at
a configuration table that tells it there are 10 options with names 1, 2, 3,
.... So it puts the 10 check boxes with the names next to them. When the user
saves them, it goes back and figures out what's been checked and updates the
database.

I can handle the reading from the table and updating the database. I'm just
looking for an easy way to find out what check boxes I need to put on the
screen and then how to access them.

TIA - Jeff.
 
Here is one way I think you can go about doing this. You can use code
like

this.checkBox1.DataBindings.Add("Checked",
this.dataTable1, "someColumnInDataTable1");

to bind the checkBox1.Checked to the boolean column named
"someColumnInDataTable1". To move from row to row in your DataTable
and see the values appear in the checkboxes, you can use a
BindingManagerBase object and change its Position property. If you
drop your checkboxes directly on the form, you can use this code to
get the BindingManagerbase.

BindingManagerBase bmb =
this.BindingContext[this.dataTable1];

Then to set a particular row, use

bmb.Position = someParticularRowIndex;

================
Clay Burch
 
Clay,
Thanks for the info but could you maybe direct me to some code?

What's this defined in - a DataGridView?

TIA - Jeff.
 
Back
Top