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

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

  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.


    "Cor Ligthert" <> wrote in message
    news:%...
    > 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
    >
    >
    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. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kris
    Replies:
    0
    Views:
    508
  2. kris
    Replies:
    0
    Views:
    476
  3. kris
    Replies:
    1
    Views:
    5,196
  4. Suresh
    Replies:
    2
    Views:
    396
    Suresh
    Apr 22, 2004
  5. pw

    Check All Check Boxes

    pw, May 24, 2005, in forum: Javascript
    Replies:
    8
    Views:
    132
    Lasse Reichstein Nielsen
    May 25, 2005
Loading...

Share This Page