i am working on a grid, i want to add a CheckBox Column in that grid to use it as a row selector
how can i do this?
thanx
Hi,
You really can't link checkboxes with selection.
You could trap the CellChange event and trap for changes to the CheckBox column and select the row, but as soon as any cell in the grid enters edit mode, the selection would be lost - and that includes clicking on a CheckBox cell.
So there's really no good way to actually select the rows based on the CheckBoxes.
You could make the rows look selected, though. All you have to do for that is handle the InitializeRow event and set the row.Appearance.BackColor and ForeColor based on the value of the CheckBox cell.
hi Mike,
thank you for your reply.
i have tested your code and it works great, and i modified your code as following:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
UltraGridColumn checkBoxColumn = e.Layout.Bands[0].Columns.Add("My CheckBox Column");
checkBoxColumn.DataType = typeof(Boolean);
checkBoxColumn.Header.CheckBoxVisibility = HeaderCheckBoxVisibility.WhenUsingCheckEditor;
}
to add a checkbox in the column header to select all the rows but this checkbox only make the checkboxes in the cells to be checked.
how can i make the CheckBox in that column header to select all the rows when it checked?
please note that i have tried to handle the BeforeCellUpdate for each CheckBox in that column,
it works but it is too slow despite of the number of columns is not big(only 30 columns)
is there is a better way to perform that?
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridColumn checkBoxColumn = e.Layout.Bands[0].Columns.Add("My CheckBox Column"); checkBoxColumn.DataType = typeof(Boolean); }