I am trying to implement an Excel-like enter key behavior where pressing enter moves to the next cell only within the selected cells. I am handling KeyDown and everything works fine using Grid.CurrentColumn to move the CurrentCell between columns. However as soon as my selection is more than one row and I need to wrap to the next row, setting Grid.CurrentColumn kills the SelectedCells collection. I tried every manner of selecting a current cell that I could find, but nothing helps. Most are worse. Using GridNavigator kills the selection for any move, and setting the IsCurrent property of the row kills the selection even if the row hasn't changed.
All of the documentation I can find explicitly states that the current cell and the selected cells are supposed to be independent. Am I missing something?
I have MultiSelect on and SelectionMode = CellSelect, and I am using VirtualMode for the data.
5 Answers, 1 is accepted
Thank you for writing.
RadGridView manages user mouse and keyboard input over its rows by GridRowBehavior. Depending on the row type, RadGridView introduces different behaviors. Thus, you can override the ProcessEnterKey of the row behavior and perform the desired logic. Additional information for implementing custom row behaviors is available at the following help article: http://docs.telerik.com/devtools/winforms/gridview/rows/row-behaviors
Note that RadGridView is supposed to keep the multiple when handling the mouse and keyboard input by holding the Shift key. If you need to keep the selection after processing the Enter key, you can store the selected cells and restore them after manipulating the current row/column. The following help article demonstrates how to select programmatically cells/rows: http://docs.telerik.com/devtools/winforms/gridview/selection/selecting-rows-and-cells-programmatically
I hope this information helps. Should you have further questions I would be glad to help.
Dess
Telerik

Thank you for writing back.
When you change the current column, the current row remains the same. Thus, when you have GridViewSelectionMode.CellSelect, you do not perform selecting a new cell. However, when you change the CurrentRow, the cell selection is changed. This is desired behavior. If you need to skip clearing the SelectedCells when setting the CurrentRow and while the Control key is not pressed, you can use a custom BaseGridNavigator and override the Select method to control whether the selection will be cleared:
public
class
CustomBaseGridNavigator : BaseGridNavigator
{
public
override
bool
Select(GridViewRowInfo row, GridViewColumn column)
{
if
(
this
.GridViewElement.Tag==
"Skip"
)
{
return
false
;
}
return
base
.Select(row, column);
}
}
public
Form1()
{
InitializeComponent();
this
.radGridView1.MultiSelect =
true
;
this
.radGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect;
this
.radGridView1.GridViewElement.Navigator =
new
CustomBaseGridNavigator();
}
private
void
radButton1_Click(
object
sender, EventArgs e)
{
this
.radGridView1.CurrentColumn =
this
.radGridView1.Columns.Last();
}
private
void
radButton2_Click(
object
sender, EventArgs e)
{
this
.radGridView1.GridViewElement.Tag =
"Skip"
;
this
.radGridView1.CurrentRow =
this
.radGridView1.Rows.First();
this
.radGridView1.GridViewElement.Tag =
null
;
}
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik

Thank you for writing back.
I have discussed this case with the team and we decided to log it in our feedback portal. You can track its progress, subscribe status changes and add your vote/comment to it on the following link - feedback item.
I have also updated your Telerik points.
Feel free to use the suggested solution to keep the selection.I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik