views:

217

answers:

1

Hello,

I want to ask if I can put the checkbox that is originated from a bit value, into state of "intermediate". Is is possible to convert any cell (bit value cells) into checkboxes?

Thank you.

A: 

you can add column of the DataGridViewCheckBoxColumn type; set its ThreeState property to true and set values for True False and Indeterminate states. Below is an example of using 3 states checkbox column to work with string values:

// add column
DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn();
column.HeaderText = "Test three state";
column.TrueValue = "a";
column.FalseValue = "b";
column.IndeterminateValue = "c";
column.ThreeState = true;
column.ValueType = typeof(string);
dataGridView2.Columns.Add(column);
// add rows
dataGridView2.Rows.Add(new object[] { "a" });
dataGridView2.Rows.Add(new object[] { "b" });
dataGridView2.Rows.Add(new object[] { "c" });

hope this helps, regards

serge_gubenko