Articles in this section
Category / Section

How to get first and last selected row index in WPF GridControl?

1 min read

You can get the first and last row index based on the selected ranges in grid using Model.SelectedRanges.Info property of GridModel class. Row selection in GridControl can be enabled by setting GridControl.Model.Options.AllowSelection as Row and GridControl.Model.Options.ListBoxSelectionMode property.

Refer below code for your reference.

C#

private void Button1_Click(object sender, RoutedEventArgs e)
{
    if (grid.Model.SelectedRanges.ActiveRange.IsRows)
    {
        var first = grid.Model.SelectedRanges.Info.Substring(0, 2);
        var last = grid.Model.SelectedRanges.Info.Substring(grid.Model.SelectedRanges.Info.Length - 2, 2);
        MessageBox.Show("first selected row" + first + Environment.NewLine + "last selected row" + last);
    }
}

 

Get the first and last selected row index

Sample: View sample in GitHub

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied