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
435
RowSelect CellClickAction and ValueLists
posted

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

 

Parents
  • 469350
    Suggested Answer
    Offline posted

    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.

Reply Children
  • 535
    posted in reply to Mike Saltzman

    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