I have the following problem:I have a column with a checkbox.I would like to select multiple rows and then click a check box.Then, all checkboxes to update the value of the modified active checkbox.
How can I do that?
Screenshot:
I found a similar topic:
http://forums.infragistics.com/forums/p/23132/84752.aspx#84752
Is there now a built in function in latest version of UltraGrid?
If not, how can I implement this function?
Regards,
Markus
Hi Markus,
No, there's no built-in way to do this. In fact, even with code, this will be a bit tricky, because clicking on a cell and entering edit mode on that cell will de-select the selected cells.
I'd recommend using a right-click menu, instead, if you can. That would certainly be easier to implement. The user could right-click on the selected cells and you could show a context menu with options for "Check All" and "Uncheck All". Then you just loop through the grid.Selected.Cells collection and update the Value of each cell.
If you must do this by a left-click, then you would probably have to disable the column or handle BeforeEnterEditMode and always cancel it for this checkbox column. This will disable the clicking behavior on the cell entirely and then you could use the grid's MouseDown event to trap for clicks on the checkbox cells and manually update the Value of the cell or cells in code as you see fit.
Scenario: All Ultragrid rows are read only, but a checkbox in front of each row should be clickable (with multiselect).
That works well for me now. I can change the selected rows checkbox's on mouse click or with SPACE key.In design mode in Ultra Grid move to your DisplayLayout.Override.CellClickAction and do this: UGrid.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect;
private void UG_Source_KeyUp(object sender, KeyEventArgs e){ bool bSelect = false; Infragistics.Win.UltraWinGrid.UltraGrid uG = (Infragistics.Win.UltraWinGrid.UltraGrid)sender; if (e.KeyValue == 32) // Space Key { bSelect = !(Convert.ToBoolean(uG.ActiveRow.Cells["CheckBoxColumn"].Value)); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow oRow in uG.Selected.Rows) { oRow.Cells["CheckBoxColumn"].Value = bSelect; oRow.Update(); } uG.ActiveRow.Cells["CheckBoxColumn"].Value = bSelect; }}
private void UG_Source_MouseDown(object sender, MouseEventArgs e){ bool bValue; Infragistics.Win.UltraWinGrid.UltraGrid uG; Infragistics.Win.UIElement UIEl; uG = (Infragistics.Win.UltraWinGrid.UltraGrid)sender; UIEl = uG.DisplayLayout.UIElement.ElementFromPoint(e.Location); if (UIEl.GetType().ToString() == "Infragistics.Win.CheckIndicatorUIElement") { bValue=!Convert.ToBoolean(((UltraGridRow)UIEl.SelectableItem).Cell["CheckBoxColumn"].Text); foreach (UltraGridRow oRow in uG.Selected.Rows) { oRow.Cells["CheckBoxColumn"].Value = bValue.ToString(); oRow.Update(); } }}
Kind regardsRalfPS: It's a real pain to insert code here with paste from Visual Studio. It look not so good in preview, so I decide to insert it first in Word and paste it with your Word insert. But now all color highlighting disapears. :( Posting here makes no fun for customers and I think you loose many examples from your costumers. -20 Post Points ;)