Hi,
I'm using an UltraWinGrid (Net 4, Version 2011.2), which is allowed to select only a single cell, though the code below
this.grid.DisplayLayout.Override.RowSelectors = DefaultableBoolean.False;this.grid.DisplayLayout.Override.SelectTypeCell = SelectType.Single;this.grid.DisplayLayout.Override.SelectTypeCol = SelectType.None;this.grid.DisplayLayout.Override.SelectTypeRow = SelectType.None;this.grid.DisplayLayout.Override.CellClickAction = CellClickAction.CellSelect
Most of the time, it works as expected.
However, in some circumstances, which appear to be a bit random and can't reproduce at will, when the user is navigating in the grid, sometimes the whole row will get selected.
The selection border will be focused on the row, and using the Up and down keys will move the selection to the row above/below. Left or Right keys have no effect because the whole row is selected.
The only way to get around that is to use the mouse to click a cell explicitily, after which the "single-cell" selected behavior is back, but it frustrates end-users.
Am I omitting to set any property or should I be watching out for anything particular here?
Thanks.
Hello Kharlos,
I wanted to know if you were able to solve your issue based on these suggestions or you still need help. Please let me know.
I am very happy that you were able to reproduce this. I used the following approach in order to achieve the desired behavior:
private void grid_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { grid.Rows[grid.Rows.VisibleRowCount - 2].Cells[0].Activate(); } }
The count-2(not count-1) is because of the 'AddNewRow'.
Please try the above code snippet and let me know if it suits your needs.
Thanks, I'm already using this trick for initialization, unfortunately it doesn't help in my case because it happens during editing rather than initialization.
I managed to reproduce the problem.
If you place yourself in the AddNewRow area and then press Escape to cancel the input of the new row, then the row above will be selected, rather than the cell.
Thanks in advance.
The only time I saw this behavior with the above code is the first time the grid initializes when I am running the application. I have put the following line to get around this:
this.grid.ActiveCell = this.grid.Rows[0].Cells[0];
I attached my sample to this post, so please take a look, modify it if necessary and please try to reproduce this behavior as I am not able to do so.