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

Discussion in 'ASP .Net Datagrid Control' started by Richard, Jun 15, 2005.

  1. Richard

    Richard Guest

    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;
     
    Richard, Jun 15, 2005
    #1
    1. Advertisements

  2. Richard

    Cor Ligthert Guest

    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
     
    Cor Ligthert, Jun 15, 2005
    #2
    1. Advertisements

  3. Richard

    Richard Guest

    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.
     
    Richard, Jun 15, 2005
    #3
  4. Richard

    Cor Ligthert Guest

    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
     
    Cor Ligthert, Jun 15, 2005
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.