Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Multi Select and Keyboard Selection

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Multi Select and Keyboard Selection
Link Posted: 21-Nov-2007 07:18
I am using the FlyGrid with and MULTIPLE COLUMNS and these options:

GridOptions.MultiSelect | GridOptions.RowSelect


If a users selected multiple rows from the grid and then tries to move the selection using the keyboard arrow keys. The selection behaves in a weird way. It selects the new row, but leaves the columns which are not active selected.
Link Posted: 21-Nov-2007 09:05
To test your case, I just took default Performance Demo,

Selected RowSelect and MultiSelect. Selected several rows with CTRL, then clicked arrow keys, and the behavior seems to be correct.

How to reproduce your case, could you please create a small test app and put it to
ftp://download.9rays.net/9r_incoming/

So we can debug it locally.

Or just steps for example for a well known Performance Demo, so we can reproduce it here.

Thanks in advance.
Link Posted: 26-Nov-2007 06:21
The ftp site is unavailable, but here is the code which can be used to reproduce the problem:


void SetupTree()
{
    this.treeTest.Options = GridOptions.MultiSelect | GridOptions.RowSelect;

    TreeViewColumn col1 = new TreeViewColumn("Description");
    col1.ReadOnly = true;   //no edit
    this.treeTest.Columns.Items.Add(col1);

    Column col2 = new Column("Value");
    col2.ReadOnly = true;   //no edit
    this.treeTest.Columns.Items.Add(col2);

    for (int i = 0; i < 10; i++)
    {
        TreeViewNode node = new TreeViewNode(new string[] { "New Node", "On" });
        this.treeTest.Rows.Items.Add(node);
    }
}


Once populated, use the Shift key to select few rows, then move the selection using the keyboard, you will see the issue. It works fine sometimes when the selection is made with the Ctrl key, so use Shift for multi-selection.
Link Posted: 26-Nov-2007 07:25
I selected few rows with Shift.
Now I press up/down keys - and the selection clears, instead flygrid selects the only (current) node.
Link Posted: 26-Nov-2007 07:25
Or do you mean left/right keys?
Link Posted: 26-Nov-2007 09:18
I am using the up/down arrow key and the selection does not clear. Even dowloaded the latest version (1.5.3.43), but that did not fix the issue. Is there a posibility that I could show you my project over Live Meeting or Webex. Any other ideas?
Link Posted: 26-Nov-2007 09:31
The ftp (see URL above) works.
Just put your application project there, so I can dedug it.

Thanks in advance.
Link Posted: 29-Jan-2008 07:56
This is the workaround, disable the multi-select in KeyDown and reenable is in KeyUp


bool this._bMultiSelectChanged = false;

void tree_KeyDown(object sender, KeyEventArgs e)
{
    if (!e.Control && !e.Shift &&
        ((this.Options & GridOptions.MultiSelect) == GridOptions.MultiSelect) &&
        this.Rows.SelectedNodes.GetLength(0) > 0)
    {
        switch (e.KeyCode)
        {
            case System.Windows.Forms.Keys.Up:
            case System.Windows.Forms.Keys.Down:
                TreeViewNode node = (TreeViewNode) this.Rows.SelectedNodes[0];

                this.Options = this.Options & ~GridOptions.MultiSelect;

                node.Selected = true;
                this._bMultiSelectChanged = true;
                break;
        }
    }
}

void tree_KeyUp(object sender, KeyEventArgs e)
{
    if (this._bMultiSelectChanged)
    {
        this.Options = this.Options | GridOptions.MultiSelect;
        this._bMultiSelectChanged = false;
    }
}