Datagrid checkbox states

  • Thread starter Thread starter Soulless
  • Start date Start date
S

Soulless

Hi, I am very new to C# and am trying to figure out DataGrids. I have
a DataGrid whos data member (I think that is what it is called) has a
checkbox on it. The checkbox defaults to a check that is greyed. We
want 2 states, not 3, on or off. Is this possible to do and if so,
how?

Thanks!
 
Soulless,

You would want to get the DataGridViewCheckBoxColumn for that column and
set the ThreeState property to false.
 
Soulless,

You would want to get the DataGridViewCheckBoxColumn for that column and
set the ThreeState property to false.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




Hi, I am very new to C# and am trying to figure out DataGrids. I have
a DataGrid whos data member (I think that is what it is called) has a
checkbox on it. The checkbox defaults to a check that is greyed. We
want 2 states, not 3, on or off. Is this possible to do and if so,
how?
Thanks!- Hide quoted text -

- Show quoted text -

I apologize for my ignorance, but where should I set this? I am
trying to find the proper method/syntax to do this.
I type this.<name of DataGrid>. but am not sure what to pick from
the list. There is not a DataGridViewCheckBoxColumn.... do I need to
specify something more?

Sorry for my ignorance, I am trying to learn as quickly as possible.
Thanks very much for your help :)
 
You can access the Columns collection, which is indexed by position, or
the name of the column. From there, you have to cast the return value to a
DataGridViewCheckBoxColumn, and then set the property:

// The column.
DataGridViewColumn column = this.gridView1.Columns["booleanColumn"];

// Cast to a DataGridViewCheckBoxColumn.
DataGridViewCheckBoxColumn checkboxColumn = (DataGridViewCheckBoxColumn)
column;

// Set the ThreeState property to false:
checkboxColumn.ThreeState = false;


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Soulless said:
Soulless,

You would want to get the DataGridViewCheckBoxColumn for that column
and
set the ThreeState property to false.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




Hi, I am very new to C# and am trying to figure out DataGrids. I have
a DataGrid whos data member (I think that is what it is called) has a
checkbox on it. The checkbox defaults to a check that is greyed. We
want 2 states, not 3, on or off. Is this possible to do and if so,
how?
Thanks!- Hide quoted text -

- Show quoted text -

I apologize for my ignorance, but where should I set this? I am
trying to find the proper method/syntax to do this.
I type this.<name of DataGrid>. but am not sure what to pick from
the list. There is not a DataGridViewCheckBoxColumn.... do I need to
specify something more?

Sorry for my ignorance, I am trying to learn as quickly as possible.
Thanks very much for your help :)
 
Back
Top