CB
Clay Burch
Syncfusion Team
June 25, 2002 05:51 PM UTC
If you are using custom column styles, then setting the AllowNull property on the bool columnstyle will avoid the tri-state checkbox.
((DataGridBoolColumn)boolCol).AllowNull = false;
You can take a look at the FAQ below that shows how you can add a column of checkboxes to your datagrid. You should also set the AllowDBNull propery to false on the DataColumn which is a member of the Columns collection on your datatable.
VB
Vipul Bhatt
June 26, 2002 02:32 AM UTC
> If you are using custom column styles, then setting the AllowNull property on the bool columnstyle will avoid the tri-state checkbox.
>
> ((DataGridBoolColumn)boolCol).AllowNull = false;
>
> You can take a look at the FAQ below that shows how you can add a column of checkboxes to your datagrid. You should also set the AllowDBNull propery to false on the DataColumn which is a member of the Columns collection on your datatable.
Ok. I will try this, but as such Clay there are no null values currently in DB. Yet it shows grayed checked checkbox.
Thanx.
VB
Vipul Bhatt
June 26, 2002 02:33 AM UTC
> If you are using custom column styles, then setting the AllowNull property on the bool columnstyle will avoid the tri-state checkbox.
>
> ((DataGridBoolColumn)boolCol).AllowNull = false;
>
> You can take a look at the FAQ below that shows how you can add a column of checkboxes to your datagrid. You should also set the AllowDBNull propery to false on the DataColumn which is a member of the Columns collection on your datatable.
Ok. I will try this, but as such Clay there are no null values currently in DB. Yet it shows grayed checked checkbox.
Thanx.
VB
Vipul Bhatt
June 26, 2002 02:57 AM UTC
> > If you are using custom column styles, then setting the AllowNull property on the bool columnstyle will avoid the tri-state checkbox.
> >
> > ((DataGridBoolColumn)boolCol).AllowNull = false;
> >
> > You can take a look at the FAQ below that shows how you can add a column of checkboxes to your datagrid. You should also set the AllowDBNull propery to false on the DataColumn which is a member of the Columns collection on your datatable.
>
> Ok. I will try this, but as such Clay there are no null values currently in DB. Yet it shows grayed checked checkbox.
> Thanx.
Hi Clay.Sorry but it didn't work. Below is the code that i used
Dim ss As DataGridBoolColumn
ss = New DataGridBoolColumn()
ss.AllowNull = False
ss.Width = 45
ss.MappingName = "Status"
ss.HeaderText = "Status"
ss.Alignment = HorizontalAlignment.Right
tsx.GridColumnStyles.Add(ss)
CB
Clay Burch
Syncfusion Team
June 26, 2002 10:07 AM UTC
Is this columnstyle being used for the column? For example, if you change the width to 200, do you see a wider column? If it is not being used, then you need to figure out why.
VB
Vipul Bhatt
June 28, 2002 05:58 AM UTC
> Is this columnstyle being used for the column? For example, if you change the width to 200, do you see a wider column? If it is not being used, then you need to figure out why.
Hi Clay.
I have attatched a small picture file with this.
It shows above 2 checkboxes(Unchecked) reflecting the database value(i.e. the value is 0[Unchecked])
You can see the same record selected in the datagrid (marked blue). Is there any property I have to set for reflecting DB value
VB
Vipul Bhatt
June 28, 2002 07:24 AM UTC
Kindly check a small picture file with this.
The 2 checkboxes(Unchecked) above reflects the database values(i.e. value=0[Unchecked])
You can see the same record selected in the datagrid below (as selected row).
Is there any property I have to set for reflecting DB value
Thanx.
CB
Clay Burch
Syncfusion Team
June 28, 2002 08:47 AM UTC
Have you set AllowDBNull to False for your datacolumn? The online help has a code snippet. You use the Columns collection on your datatable. Maybe something like
MyTable.Columns(3).AllowDBNull = False
VB
Vipul Bhatt
June 28, 2002 09:50 AM UTC
> Have you set AllowDBNull to False for your datacolumn? The online help has a code snippet. You use the Columns collection on your datatable. Maybe something like
>
> MyTable.Columns(3).AllowDBNull = False
Sorry Clay, but it does not work.
VB
Vipul Bhatt
July 1, 2002 11:22 AM UTC
> > Have you set AllowDBNull to False for your datacolumn? The online help has a code snippet. You use the Columns collection on your datatable. Maybe something like
> >
> > MyTable.Columns(3).AllowDBNull = False
>
>
> Sorry Clay, but it does not work.
Can U please look into it.
Thanx a lot.
VB
Vipul Bhatt
July 3, 2002 07:06 AM UTC
> > > Have you set AllowDBNull to False for your datacolumn? The online help has a code snippet. You use the Columns collection on your datatable. Maybe something like
> > >
> > > MyTable.Columns(3).AllowDBNull = False
> >
> >
> > Sorry Clay, but it does not work.
>
> Can U please look into it.
> Thanx a lot.
Hi Clay.
Clay there is no response from you.
VB
Vipul Bhatt
July 3, 2002 07:41 AM UTC
> > > > Have you set AllowDBNull to False for your datacolumn? The online help has a code snippet. You use the Columns collection on your datatable. Maybe something like
> > > >
> > > > MyTable.Columns(3).AllowDBNull = False
> > >
> > >
> > > Sorry Clay, but it does not work.
> >
> > Can U please look into it.
> > Thanx a lot.
>
> Hi Clay.
> Clay there is no response from you.
Clay i just found the ans for displaying the checkbox in the datagrid. I am using SQL server.
I had defined that field as smallint. When i changed it to 'bit' it worked.
A BIG THANX for all your support.
MS
Michael Sparks
October 9, 2002 02:41 PM UTC
I ran into the same problem having a field defined as smallint. Unfortunately, I could not change the field datatype to bit.
My solution was to build the dataset's table and columns in code and set the column of interest to a System.Boolean.
For example:
DataTable dt = new DataTable("Table");
DataColumn idColumn = new DataColumn("ID", System.Type.GetType("System.Int16"));
DataColumn columnOfInterestColumn = new DataColumn("ColumnOfInterest", System.Type.GetType("System.Boolean"));
dt.Columns.Add(idColumn);
dt.Columns.Add(columnOfInterestColumn);
ds.Tables.Add(dt);
HTH,
Michael
> > > > > Have you set AllowDBNull to False for your datacolumn? The online help has a code snippet. You use the Columns collection on your datatable. Maybe something like
> > > > >
> > > > > MyTable.Columns(3).AllowDBNull = False
> > > >
> > > >
> > > > Sorry Clay, but it does not work.
> > >
> > > Can U please look into it.
> > > Thanx a lot.
> >
> > Hi Clay.
> > Clay there is no response from you.
>
>
> Clay i just found the ans for displaying the checkbox in the datagrid. I am using SQL server.
> I had defined that field as smallint. When i changed it to 'bit' it worked.
>
> A BIG THANX for all your support.
AD
Administrator
Syncfusion Team
September 8, 2006 07:17 PM UTC
I had a similar problem with the dataGridBoolColumn.I just had to change the Datagrid property readonly to false and worked fine
>I ran into the same problem having a field defined as smallint. Unfortunately, I could not change the field datatype to bit.
>My solution was to build the dataset''s table and columns in code and set the column of interest to a System.Boolean.
>
>For example:
>DataTable dt = new DataTable("Table");
>DataColumn idColumn = new DataColumn("ID", System.Type.GetType("System.Int16"));
>DataColumn columnOfInterestColumn = new DataColumn("ColumnOfInterest", System.Type.GetType("System.Boolean"));
>dt.Columns.Add(idColumn);
>dt.Columns.Add(columnOfInterestColumn);
>ds.Tables.Add(dt);
>
>
>
>
>HTH,
>Michael
>
>
>
>
>
>> > > > > Have you set AllowDBNull to False for your datacolumn? The online help has a code snippet. You use the Columns collection on your datatable. Maybe something like
>> > > > >
>> > > > > MyTable.Columns(3).AllowDBNull = False
>> > > >
>> > > >
>> > > > Sorry Clay, but it does not work.
>> > >
>> > > Can U please look into it.
>> > > Thanx a lot.
>> >
>> > Hi Clay.
>> > Clay there is no response from you.
>>
>>
>> Clay i just found the ans for displaying the checkbox in the datagrid. I am using SQL server.
>> I had defined that field as smallint. When i changed it to ''bit'' it worked.
>>
>> A BIG THANX for all your support.
SB
Sevil Bähr
May 4, 2007 08:24 AM UTC
use this code:
myDataset.Tables[0].Columns[myIndex].DefaultValue=0;
SW
Swapnil
replied to Clay Burch
February 24, 2018 11:49 AM UTC
If you are using custom column styles, then setting the AllowNull property on the bool columnstyle will avoid the tri-state checkbox.
((DataGridBoolColumn)boolCol).AllowNull = false;
You can take a look at the FAQ below that shows how you can add a column of checkboxes to your datagrid. You should also set the AllowDBNull propery to false on the DataColumn which is a member of the Columns collection on your datatable.
Need Community Edition
ST
SaBrena Toler
Syncfusion Team
February 27, 2018 09:00 PM UTC
Hello Vipul,
We thank you for your interest in our controls. I have forwarded your inquiry to our Sales Department; one of our team members will contact you shortly.
Please be advised that I am closing this incident; please let me know if you have any questions.
Best,
SaBrena