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.
Unfortunately, activation email could not send to your email. Please try again.

How do I retrieve arbitrary selected ranges?

 

Description

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.

 

C#

 

VB

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#

 

VB

Sample

C#: Retrieves SelectedRanges CS

VB: Retrieves SelectedRanges VB

Article ID: Published Date: Last Revised Date: Platform: Control:
625 04/30/2011 02/08/2017 Windows Forms GridControl
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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.