DataGridBoolColumn

G

Guest

Hi,
my code is:

myDataTBL.Columns.Add("checked",System.Type.GetType("System.Boolean"));
DataGridBoolColumn cs1 = new DataGridBoolColumn();
cs1.NullValue=false;
cs1.TrueValue=true;
cs1.FalseValue=false;
cs1.MappingName="checked";
cs1.ReadOnly=false;
dataGrid1.TableStyles[0].GridColumnStyles.Add(cs1);


what i get is always a gray checkbox. When i click it, it becomes checked,
and another click turns it into grey, and then unchecked act...
I want:
a. default value is uncheked
b. only to states - checked/unchecked (no gray)

what should i do... please help..
 
N

Nicholas Paldino [.NET/C# MVP]

Ubi,

First, you should change the following line:

myDataTBL.Columns.Add("checked",System.Type.GetType("System.Boolean"));

To:

myDataTBL.Columns.Add("checked", typeof(bool));

Then, on the DataGridBoolColumn that you create (cs), set the AllowNull
property to false.

Hope this helps.
 
G

Guest

This is working, except the starting value is grey.
after i click it the first time i don't get gray check anymore...
but how can i change the starting value to unchecked?




Nicholas Paldino said:
Ubi,

First, you should change the following line:

myDataTBL.Columns.Add("checked",System.Type.GetType("System.Boolean"));

To:

myDataTBL.Columns.Add("checked", typeof(bool));

Then, on the DataGridBoolColumn that you create (cs), set the AllowNull
property to false.

Hope this helps.


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


Ubi said:
Hi,
my code is:

myDataTBL.Columns.Add("checked",System.Type.GetType("System.Boolean"));
DataGridBoolColumn cs1 = new DataGridBoolColumn();
cs1.NullValue=false;
cs1.TrueValue=true;
cs1.FalseValue=false;
cs1.MappingName="checked";
cs1.ReadOnly=false;
dataGrid1.TableStyles[0].GridColumnStyles.Add(cs1);


what i get is always a gray checkbox. When i click it, it becomes checked,
and another click turns it into grey, and then unchecked act...
I want:
a. default value is uncheked
b. only to states - checked/unchecked (no gray)

what should i do... please help..
 
J

Jack Addington

You have to set the value to false. Basically True = checked, False =
unchecked, Null = 3rd State/Gray

Ubi said:
This is working, except the starting value is grey.
after i click it the first time i don't get gray check anymore...
but how can i change the starting value to unchecked?




Nicholas Paldino said:
Ubi,

First, you should change the following line:

myDataTBL.Columns.Add("checked",System.Type.GetType("System.Boolean"));

To:

myDataTBL.Columns.Add("checked", typeof(bool));

Then, on the DataGridBoolColumn that you create (cs), set the AllowNull
property to false.

Hope this helps.


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


Ubi said:
Hi,
my code is:

myDataTBL.Columns.Add("checked",System.Type.GetType("System.Boolean"));
DataGridBoolColumn cs1 = new DataGridBoolColumn();
cs1.NullValue=false;
cs1.TrueValue=true;
cs1.FalseValue=false;
cs1.MappingName="checked";
cs1.ReadOnly=false;
dataGrid1.TableStyles[0].GridColumnStyles.Add(cs1);


what i get is always a gray checkbox. When i click it, it becomes checked,
and another click turns it into grey, and then unchecked act...
I want:
a. default value is uncheked
b. only to states - checked/unchecked (no gray)

what should i do... please help..
 

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