Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
926
Adding Checkbox to the wingrid column
posted

Hello 

I have some data in dataset and I want to bind that dataset to DataGrid that I have perfectly done but I want to insert a column of check box so that user can select the row of Datagrid and perform the operation on those rows the user has been selected. How I can insert a column of checkbox.

I also need to show checkbox only to few rows.Say I have 10 rows in the dataset. Depending on the type, I need to put checkbox only for 3 rows out of 10.

Is this possible ??

 

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi,

        Yes. What you would do is use the InitializeLayout event of the grid to add a column to the band. Assuming you are talking about the root band, the code would look something like this:

    UltraGridColumn checkBoxColumn = e.Layout.Bands[0].Columns.Add("My CheckBox Column"); 

    checkBoxColumn.DataType = typeof(bool);

         This will give you a checkbox column, since a boolean field defaults to a checkbox.

        To only have the checkbox show up in certain cells, you will want to use the InitializeRow event. This event fires for each row, so you would examine the row and it's properties and if you don't want that row to show a CheckBox, you can set the Style property on the cell to Picture. Or you could set the Hidden property on the cell to false. Either one would work.  

Children