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 ??
My post above is already talking about an unbound checkbox column.
Just make sure you check that e.Row.Cells.Exists("My Unbound CheckBox column") is true before you try to access it in InitializeRow.
How would you handle this if you were adding an unbound checkbox to the grid? The InitailizRow event is fired before the InitializeLayout event is.
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.