Home Forums WPF controls Xceed DataGrid for WPF selecting row on right click

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #25729 |

    How do I select a row on a right click.

    Thanx,
    Alex.

    Imported from legacy forums. Posted by Alex (had 1967 views)

    User (Old forums)
    Member
    Post count: 23064

    Nevermind… got it

    private void grd_MouseDown(object sender, MouseButtonEventArgs e)
    {
    if (e.RightButton == MouseButtonState.Pressed)
    {
    foreach (var item in grd.Items)
    {
    var row = grd.GetContainerFromItem(item);
    if (row is DataRow && ((DataRow)row).IsMouseOver)
    {
    grd.SelectedItem = item; // or SelectedItems.Add()… depends on selection mode
    break;
    }
    }
    }
    }

    the only problem is that it does not work if I right click the row selector.

    Imported from legacy forums. Posted by Alex (had 3176 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.