By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,219 Members | 2,361 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,219 IT Pros & Developers. It's quick & easy.

Datagrid - Windows - DataGridBoolColumn - How can I disable all the check boxes in the column

P: n/a
I tried boolCol.ReadOnly = true and a bunch of other things but can't get
the check boxes for the datagrid's column for all rows to be disabled? Can
someone tell me how to do this?

MyGrid.ReadOnly = true;

MyGrid.Click += new EventHandler(MyGrid_Click);

MyGrid.CaptionVisible = false;

tableStyle = new DataGridTableStyle();

tableStyle.MappingName = "MyItemsData";

tableStyle.AllowSorting = false;

tableStyle.RowHeadersVisible = false;

//MyCheckBox Check

boolCol = new DataGridBoolColumn();

boolCol.MappingName = "MyCheckBox";

boolCol.HeaderText = "MyCheckBox";

boolCol.AllowNull = true;

boolCol.NullValue = string.Empty;

boolCol.FalseValue = false;

boolCol.TrueValue = true;

boolCol.Width = boolColWidth;

tableStyle.GridColumnStyles.Add(boolCol);

boolCol = null;
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Richard,

From your code I get the idea that you are using a windowforms datagrid,
but when I see the newsgroups you are posting to, than you bring me in
doubt.

Therefore a short answer. For a windowsform datagrid is the bool column only
representing the status in the underlying datasource. Therefore you need to
set the underlying datasource to the values you want.

I hope this helps,

Cor
Nov 21 '05 #2

P: n/a
Yes, it is bound to a DataTable. I had a feeling that it would have to be a
manual process of going through the datatable and setting the booleans to
whatever. I did not realize I was posting to the aspnet group.
"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Richard,

From your code I get the idea that you are using a windowforms datagrid,
but when I see the newsgroups you are posting to, than you bring me in
doubt.

Therefore a short answer. For a windowsform datagrid is the bool column only representing the status in the underlying datasource. Therefore you need to set the underlying datasource to the values you want.

I hope this helps,

Cor

Nov 21 '05 #3

P: n/a
Richard,

Maybe does this sample that I just made do what you want.

\\\\
Dim dt As New DataTable
dt.Columns.Add("MyColumn", GetType(System.Boolean))
dt.LoadDataRow(New Object() {True}, True)
dt.LoadDataRow(New Object() {True}, True)
dt.LoadDataRow(New Object() {True}, True)
dt.LoadDataRow(New Object() {True}, True)
Dim ts As New DataGridTableStyle
ts.MappingName = dt.TableName
Dim column As New DataGridBoolColumn
ts.GridColumnStyles.Add(column)
DataGrid1.TableStyles.Add(ts)
column.MappingName = dt.Columns(0).ColumnName
column.ReadOnly = True
DataGrid1.DataSource = dt
///
I hope this helps,

Cor
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.