Difficulty With The DataGrid

S

sianan

I have a DataGrid which displays data from a table in a MS SQL 2000
database. My problem is that I have a bit column in the database whose
values I want to display as checkboxes in the DataGrid. I want to
display "1" values (True) as checked boxes, and "0" values (False) as
unchecked boxes. I haven't been able to figure out how to do this. I
also want to be able to propagate changes from the DataGrid immediately
back to the database , and I have no idea of how to do that either. In
other words, if I check off a column, the column in the database will
be changed, so that is contains a "1" (or a "0" if unchecked). (Of
course, this would be a lot easier if I knew how to get this column to
display as a checkbox in the first place.)

As always, help is greatly appreciated.
 
N

Nicholas Paldino [.NET/C# MVP]

sianan,

First, you will want to use the DataGridBoolColumn class. You will have
to set the data grid (specifically the column style for the table you want
to show in the grid) to use this type of control.

Once you do that, it should show a checkbox.

Now, in order to propogate the changes back to the database immediately,
you will have to hook up to an event to indicate when the data has changed.
What you should do is attach to the RowChanged event on the DataTable and
then feed the row to the Update method on your OleDbDataAdapter class which
can update the data.

Hope this helps.
 
F

Frank Dzaebel

Hello sianan,
I have a DataGrid which displays data from a table in a MS SQL 2000
database. My problem is that I have a bit column in the database whose
values I want to display as checkboxes in the DataGrid. I want to
display "1" values (True) as checked boxes, and "0" values (False) as
unchecked boxes.

[How can I catch the bool values changing in a DataGridBoolColumn]
http://www.syncfusion.com/faq/windowsforms/search/874.aspx

[How can I put a checkbox in a column of my
DataGrid]http://www.syncfusion.com/faq/windowsforms/search/754.aspx


ciao Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top