How to select cell in RadGridView by right mouse click?
The following code doesn't work:
private void RadGridView_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
// ... getting grid and cell
if (e.RightButton == MouseButtonState.Pressed)
{
grid.UnselectAll();
grid.CurrentCellInfo = new GridViewCellInfo(cell);
cell.IsCurrent = true;
cell.IsSelected = true;
}
}
It's strange, but selecting row works fine:
if (e.RightButton == MouseButtonState.Pressed)
{
grid.UnselectAll();
row.IsSelected = true;
row.IsCurrent = true;
}
if (e.RightButton == MouseButtonState.Pressed)
{
grid.Focus();
grid.UnselectAll();
grid.CurrentCellInfo = new GridViewCellInfo(cell);
grid.SelectedCells.Add(grid.CurrentCellInfo);
}