We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I retrieve arbitrary selected ranges?

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: February 8, 2017
Tags: selection



Ranges can be of different types:

  • row ranges
  • column ranges
  • cell ranges
  • table ranges

When a range object is a row range, then its range.Top and range.Bottom properties are populated to reflect the top and bottom rows of the range but, its range.Left and range.Right are indeterminate at this point.

Similarly, column ranges have range.Left and range.Right defined but, not top and bottom. So, before you can arbitrarily start using the properties of a range, you must check its type to see what properties are valid.

Converting an arbitrary range to cell range

The only range type that has all its properties populated are cells. So, when you are given an arbitrary range, you must make sure that all of its properties are populated by using range.ExpandRange that forces all the properties to be defined.





After running the above codes, the range becomes a Cell Range.

Retrieving selected ranges

To iterate through the arbitrary selected ranges, you must use the Selections.GetSelectedrange in code as follows.





C#: Retrieves SelectedRanges CS

VB: Retrieves SelectedRanges VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon