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

R

Richard

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;
 
C

Cor Ligthert

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
 
R

Richard

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.
 
C

Cor Ligthert

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top