I'm trying to make a grid have the ability to select a row and also allow the one column to contain a value list combobox. Currently when I set the CellClickAction to RowSelect I am no longer able to pick or edit an item from the column with the valuelist attached to it. I was hoping I could get a behavior similar to having the whole row select with 1 click, but if the user clicks again on the valuelist column the combobox will display. Is this behavior possible with the ultrawingrid? If not is there at least some way of making both of these features work together?
Here is sample code from my InitializeLayout event.
ugInvoice.DisplayLayout.Bands(0).Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect
'Add Items to the list With e.Layout.ValueLists("vlInvoiceGroups").ValueListItems For Each r As DataRow In commonInvoiceGroups.Rows .Add(r("InvoiceGroupName"), r("InvoiceGroupName")) Next End With
Here is what I ended up doing that seems to work fairly well, other than one issue which I believe is unrelated (http://forums.infragistics.com/forums/p/22212/80886.aspx#80886)
set the CellClickAction to CellSelect, then the following code:
private int nUG1ClickCount = 0;
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { this.ultraGrid1.AfterCellActivate += new EventHandler(this.ultraGrid1_CellActivateEvent); this.ultraGrid1.BeforeCellDeactivate += new CancelEventHandler(this.ultraGrid1_CellDeActivateEvent); this.ultraGrid1.MouseDown += new MouseEventHandler(ultraGrid1_MouseDown); }
public void ultraGrid1_CellActivateEvent(object sender, EventArgs e) { if (ultraGrid1.ActiveCell != null && ultraGrid1.ActiveCell.Column.Editor.GetType() != typeof(Infragistics.Win.EditorWithText) && ultraGrid1.ActiveCell.Column.Editor.GetType() != typeof (Infragistics.Win.EditorWithCombo) ) ultraGrid1.PerformAction(UltraGridAction.EnterEditMode); nUG1ClickCount = 0; }
public void ultraGrid1_CellDeActivateEvent(object sender, CancelEventArgs e) { Console.WriteLine("de-activate "); nUG1ClickCount = 1; }
void ultraGrid1_MouseDown(object sender, MouseEventArgs e) { Infragistics.Win.UIElement UIElement = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(new Point(e.X, e.Y)); object cell = UIElement.GetContext(typeof(Infragistics.Win.UltraWinGrid.UltraGridCell)); if (cell != null && ++nUG1ClickCount >= 2) ultraGrid1.PerformAction(UltraGridAction.EnterEditMode); }
This will allow a singleclick cell select, and a subsequent 2nd click will show the editor. Note: I have not tested all possible subcontrls (ie spins, sliders, calendar) but the framework should get you started.
Peter
Yes, using CellClickAction will only let the user dropdown the list immediately on the first click - not select the row the first click and edit on the second.
Unfortunately if you read the initial request this wont work.
There is no available mode in the grid for... let's call it 2nd click edit. You can read this thread here for a workaround (albeit very inelegeant): http://forums.infragistics.com/forums/p/784/20830.aspx#20830. Ignore the 1st half and start with : can we return to the original question
What version of the grid are you using? Recently, the CellClickAction property was added to the Column as well as the Override. So you could set CellClickAction on the column with the DropDown to something different than the other columns.