Search code examples
c#infragistics

How to disable dragselection in Infragistics UltraGrid


I use Infragistics UltraGrid and I'm trying to disable drag selection. I have to limit selecting multiple rows only by holding down shift or control key.

In my InitializeComponent() function I'm setting ultragrid like this:

ultragrid.DisplayLayout.Override.SelectTypeCell = SelectType.ExtendedAutoDrag
ultragrid.DisplayLayout.Override.CellClickAction = CellClickAction.RowSelect

Solution

  • You can disable any selection in UltraGrid when shift or control keys are not pressed by canceling BeforeSelectChange event in this scenarios.

    private void UltraGrid1_BeforeSelectChange(object sender, BeforeSelectChangeEventArgs e)
    {           
        if (Control.ModifierKeys != Keys.Shift && Control.ModifierKeys != Keys.Control)
        {
            e.Cancel = true;
        }
    }