Professional Web Applications Themes

Datagrid - Windows - DataGridBoolColumn - How can I disable all the check boxes in the column - ASP.NET Data Grid Control

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

  1. #1

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

    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 Guest

  2. #2

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

    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 Guest

  3. #3

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

    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" <notmyfirstnameplanet.nl> wrote in message
    news:%23L1aF9WcFHA.2984TK2MSFTNGP15.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
    >
    >

    Richard Guest

  4. #4

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

    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 Guest

Similar Threads

  1. calculate number of checked boxes in datagrid column
    By lak25 in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: December 23rd, 06:09 PM
  2. How to add a hyperlink column to a datagrid in a windows application
    By shinuda@hotmail.com in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: October 10th, 04:09 PM
  3. Check boxes on a Datagrid
    By Robert E. Flaherty in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: June 23rd, 02:44 PM
  4. Editable datagrid with drop downs and check boxes - sample code?
    By Leah in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: September 23rd, 07:18 PM
  5. With Column in a DataGrid in a Windows Application
    By Camila Pedocchi in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: November 11th, 01:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139