Class GridRangeInfo
Implements a range of cells in the grid. Possible range types are: Row(s), Column(s), Cell(s), Table or Empty. GridRangeInfo is immutable.
Implements
Inherited Members
Namespace: Syncfusion.Windows.Forms.Grid
Assembly: Syncfusion.Grid.Windows.dll
Syntax
public class GridRangeInfo : IFormattable, ICloneable, ISerializable
Constructors
GridRangeInfo()
Initializes an empty instance ofGridRangeInfo class.
Declaration
public GridRangeInfo()
Remarks
This constructor initializes a new GridRangeInfo object with empty range type.
GridRangeInfo(SerializationInfo, StreamingContext)
Initializes a new instance ofGridRangeInfo from a serialization stream.
Declaration
protected GridRangeInfo(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.Serialization.SerializationInfo | info | An object that holds all the data needed to serialize or de-serialize this instance. |
System.Runtime.Serialization.StreamingContext | context | Describes the source and destination of the serialized stream specified by info. |
Fields
Empty
Represents a GridRangeInfo with its properties left uninitialized and range type set to GridRangeInfoType.Empty.
Declaration
public static readonly GridRangeInfo Empty
Field Value
Type |
---|
GridRangeInfo |
Remarks
A range is defined by its coordinates and range type. If uninitialized, the range type is GridRangeInfoType.Empty
Properties
Bottom
Gets the row index of the bottom-right corner of the cell range.
Declaration
public int Bottom { get; }
Property Value
Type |
---|
System.Int32 |
Height
Gets the height of the range defined by this GridRangeInfo.
Declaration
public int Height { get; }
Property Value
Type |
---|
System.Int32 |
Info
Gets results of ToString method.
Declaration
public string Info { get; }
Property Value
Type |
---|
System.String |
IsCells
Gets a value indicating whether
true if this represents a range of individual cells.
Declaration
public bool IsCells { get; }
Property Value
Type |
---|
System.Boolean |
IsCols
Gets a value indicating whether
true if this represents a range of columns.
Declaration
public bool IsCols { get; }
Property Value
Type |
---|
System.Boolean |
IsEmpty
Gets a value indicating whether this GridRangeInfo has a GridRangeInfoType of Empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
System.Boolean | true if GridRangeInfoType is Empty; otherwise, false. |
IsRows
Gets a value indicating whether
true if this represents a range of rows.
Declaration
public bool IsRows { get; }
Property Value
Type |
---|
System.Boolean |
IsTable
Gets a value indicating whether
true if this represents a table.
Declaration
public bool IsTable { get; }
Property Value
Type |
---|
System.Boolean |
Left
Gets the column index of the upper-left corner of the cell range.
Declaration
public int Left { get; }
Property Value
Type |
---|
System.Int32 |
RangeType
Gets the GridRangeInfoType of this GridRangeInfo object.
Declaration
public GridRangeInfoType RangeType { get; }
Property Value
Type |
---|
GridRangeInfoType |
Right
Gets the column index of the bottom-right corner of the cell range.
Declaration
public int Right { get; }
Property Value
Type |
---|
System.Int32 |
Top
Gets the row index of the upper-left corner of the cell range.
Declaration
public int Top { get; }
Property Value
Type |
---|
System.Int32 |
Width
Gets the width of the range defined by this GridRangeInfo.
Declaration
public int Width { get; }
Property Value
Type |
---|
System.Int32 |
Methods
Auto(Int32, Int32)
Creates a new GridRangeInfo object for the specified row and column.
Declaration
public static GridRangeInfo Auto(int rowIndex, int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. -1 to create a range of columns or whole table. |
System.Int32 | colIndex | The column index. -1 to create a range of rows or whole table. |
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
Remarks
If both row and column index are less than zero, a table will be created. If row index is less than zero and column index greater or equal to zero, a column range will be created. If row index is greater or equal to zero and column index less than zero, a row range will be created. Otherwise a cell range is created.
Examples
This example shows how to set the range for the specified row and column.
GridRangeInfo cellRange = GridRangeInfo.Auto(4, 5);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Auto(4, 5)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
Auto(Int32, Int32, Int32, Int32)
Creates a new GridRangeInfo object for the specified rows and columns.
Declaration
public static GridRangeInfo Auto(int top, int left, int bottom, int right)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | top | The row index. -1 to create a range of columns or whole table. |
System.Int32 | left | The column index. -1 to create a range of rows or whole table. |
System.Int32 | bottom | Bottom row index. |
System.Int32 | right | Right column index. |
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
Remarks
If both row and column index are less than zero, a table will be created. If row index is less than zero and column index greater or equal to zero, a column range will be created. If row index is greater or equal to zero and column index less than zero, a row range will be created. Otherwise a cell range is created.
Examples
This example shows how to set the range automatically depending on the specified values.
GridRangeInfo cellRange = GridRangeInfo.Auto(2, 5, 4, 6);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Auto(2, 5, 4, 6)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
Cell(Int32, Int32)
Creates a new GridRangeInfo object for the specified row and column index.
Declaration
public static GridRangeInfo Cell(int row, int col)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | row | The row index. |
System.Int32 | col | The column index. |
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
Examples
This example shows how to set the RangeInfo for specified cell.
GridRangeInfo cellRange = GridRangeInfo.Cell(4, 5);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Cell(4, 5)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
Cells(Int32, Int32, Int32, Int32)
Creates a new GridRangeInfo object with the specified bounds.
Declaration
public static GridRangeInfo Cells(int top, int left, int bottom, int right)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | top | The row index of the upper-left corner of the cell range. |
System.Int32 | left | The column index of the upper-left corner of the cell range. |
System.Int32 | bottom | The row index of the bottom-right corner of the cell range. |
System.Int32 | right | The column index of the bottom-right corner of the cell range. |
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
Examples
This example shows how to set the RangeInfo for specified cells.
GridRangeInfo cellRange = GridRangeInfo.Cells(3, 4, 6, 7);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Cells(3, 4, 6, 7)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
Clone()
Creates an exact copy of this GridRangeInfo object.
Declaration
public virtual object Clone()
Returns
Type | Description |
---|---|
System.Object | The GridRangeInfo object that this method creates. |
Col(Int32)
Creates a new GridRangeInfo object for the specified column.
Declaration
public static GridRangeInfo Col(int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | colIndex | The column index of the cell range. |
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
Examples
This example shows how to set the RangeInfo for specified column.
GridRangeInfo cellRange = GridRangeInfo.Col(3);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Col(3)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
Cols(Int32, Int32)
Creates a new GridRangeInfo object for the specified columns.
Declaration
public static GridRangeInfo Cols(int left, int right)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | left | The left column index of the cell range. |
System.Int32 | right | The right column index of the cell range. |
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
Examples
This example shows how to set the RangeInfo for specified columns.
GridRangeInfo cellRange = GridRangeInfo.Cells(3, 4);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Cells(3, 4)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
Compare(GridRangeInfo, GridRangeInfo)
Determines whether the two range objects are equal or not.
Declaration
public static bool Compare(GridRangeInfo r1, GridRangeInfo r2)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | r1 | The left-hand side of the operator. |
GridRangeInfo | r2 | The right-hand side of the operator. |
Returns
Type | Description |
---|---|
System.Boolean | returns boolean. |
Contains(GridRangeInfo)
Determines if this range fully contains all of range
.
Declaration
public bool Contains(GridRangeInfo range)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | range | The range to test. |
Returns
Type | Description |
---|---|
System.Boolean | true if range is a subset of this range. |
CopyAllMembers(GridRangeInfo)
Copies the all members of GridRangeInfo. Used internally.
Declaration
protected void CopyAllMembers(GridRangeInfo rg)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | rg |
EmptyRange()
Returns Empty that is an empty range.
Declaration
public static GridRangeInfo EmptyRange()
Returns
Type | Description |
---|---|
GridRangeInfo | An empty range object. |
Equals(Object)
Determines whether the specified System.Object is equal to the current System.Object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The System.Object to compare with the current System.Object. |
Returns
Type | Description |
---|---|
System.Boolean | true if the specified System.Object is equal to the current System.Object; otherwise, false. |
Overrides
ExpandRange(Int32, Int32, Int32, Int32)
Convert column and row ranges into cell ranges with the specified bounds. (Could also be done through IntersectRange ... if nFirstRow >= nFirstCol >= 0).
Declaration
public GridRangeInfo ExpandRange(int nFirstRow, int nFirstCol, int nRowCount, int nColCount)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | nFirstRow | Row index for the first non-label cell in grid area. |
System.Int32 | nFirstCol | Column index for the first non-label cell in grid area. |
System.Int32 | nRowCount | Last row in the grid. |
System.Int32 | nColCount | Last column in the grid |
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
Remarks
Column ranges will be converted to cell ranges using nFirstRow and nRowCount. Row ranges will be converted to cell ranges using nFirstCol and nColCount. Column ranges will be converted to cell ranges using all input parameters.
FromTlhw(Int32, Int32, Int32, Int32)
Creates a new GridRangeInfo object with the specified bounds.
Declaration
public static GridRangeInfo FromTlhw(int top, int left, int height, int width)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | top | The row index of the upper-left corner of the cell range. |
System.Int32 | left | The column index of the upper-left corner of the cell range. |
System.Int32 | height | Number of rows to span. |
System.Int32 | width | Number of columns to span. |
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
GetAlphaLabel(Int32)
Returns a string in the format "A, B, C, ... AA, AB ..." to be used for column labels.
Declaration
public static string GetAlphaLabel(int nCol)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | nCol | The column index. |
Returns
Type | Description |
---|---|
System.String | A string that contains the column label for the column index. |
GetFirstCell(out Int32, out Int32)
Enumerate through all cells in range object.
Declaration
public bool GetFirstCell(out int top, out int left)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | top | The row index of the upper-left corner of the cell range. |
System.Int32 | left | The column index of the upper-left corner of the cell range. |
Returns
Type | Description |
---|---|
System.Boolean | This method returns the first cell in the range. |
GetHashCode()
Serves as a hash function for a particular type.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A hash code for the current object. |
Overrides
GetNextCell(ref Int32, ref Int32)
Determines whether the adjacent cell in the range for the given row and column index.
Declaration
public bool GetNextCell(ref int nRow, ref int nCol)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | nRow | The row index. |
System.Int32 | nCol | The column index. |
Returns
Type | Description |
---|---|
System.Boolean | true if an adjacent cell in this GridRangeInfo object coud be found; otherwise, false. |
GetNextCell(ref Int32, ref Int32, Boolean)
Determines whether the adjacent cell in the range for the given row and column index.
Declaration
public bool GetNextCell(ref int nRow, ref int nCol, bool bSortByRow)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | nRow | The row index. |
System.Int32 | nCol | The column index. |
System.Boolean | bSortByRow | true if the range should be traversed by row; false if the range should be traversed by column. |
Returns
Type | Description |
---|---|
System.Boolean | true if an adjacent cell in this GridRangeInfo object could be found; otherwise, false. |
GetNumericLabel(Int32)
Returns a numeric string in the format to be used for row labels.
Declaration
public static string GetNumericLabel(int nRow)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | nRow | The row index. |
Returns
Type | Description |
---|---|
System.String | A string that contains the row label for the row index. |
GetObjectData(SerializationInfo, StreamingContext)
Implements the ISerializable interface and returns the data needed to serialize the GridRangeInfo.
Declaration
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.Serialization.SerializationInfo | info | A SerializationInfo object containing the information required to serialize the object. |
System.Runtime.Serialization.StreamingContext | context | A StreamingContext object containing the source and destination of the serialized stream. |
IntersectRange(GridRangeInfo)
Creates a new GridRangeInfo with the intersection of itself and the specified GridRangeInfo.
Declaration
public GridRangeInfo IntersectRange(GridRangeInfo range)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | range | The GridRangeInfo with which to intersect. |
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
Examples
The following example creates two GridRangeInfo objects and creates a GridRangeInfo with their intersection:
GridRangeInfo firstRange = new GridRangeInfo(0, 0, 100, 100);
IntersectRange(GridRangeInfo, GridRangeInfo)
Creates a new GridRangeInfo with the intersection of two GridRangeInfo parameters.
Declaration
public static GridRangeInfo IntersectRange(GridRangeInfo r1, GridRangeInfo r2)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | r1 | The first GridRangeInfo with which to intersect. |
GridRangeInfo | r2 | The second GridRangeInfo with which to intersect. |
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
Examples
The following example creates two GridRangeInfo objects and creates a GridRangeInfo with their intersection:
GridRangeInfo firstRange = new GridRangeInfo(0, 0, 100, 100);
IntersectsWith(GridRangeInfo)
Determines if this range intersects with range
.
Declaration
public bool IntersectsWith(GridRangeInfo range)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | range | The range to test. |
Returns
Type | Description |
---|---|
System.Boolean | true if there is any intersection. |
Examples
The following example creates two cell ranges and tests whether they intersect:
GridRangeInfo firstRange = new GridRangeInfo(1, 1, 100, 100);
...
OffsetRange(Int32, Int32)
Adjusts the location of this range by the specified amount.
Declaration
public GridRangeInfo OffsetRange(int rowOffset, int colOffset)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowOffset | Amount of rows to offset the location. |
System.Int32 | colOffset | Amount of columns to offset the location. |
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
Parse(String)
Creates a range object from a string.
Declaration
public static GridRangeInfo Parse(string parseText)
Parameters
Type | Name | Description |
---|---|---|
System.String | parseText | The text with text representation of the range. |
Returns
Type | Description |
---|---|
GridRangeInfo | The GridRangeInfo with coordinates specified in the string. |
Remarks
The method parses a string that was previously created with ToString().
The string should be in the format R#C#, R#, C#, T.
An example for a range of cells is "R1C1:R10C20" or "R5C5".
An example for a range of rows is "R1:R10" or "R6".
An example for a range of columns is "C1:C10" or "C7".
An example for a table range is "T".
Exceptions
Type | Condition |
---|---|
System.FormatException | If |
Row(Int32)
Creates a new GridRangeInfo object for the specified row index.
Declaration
public static GridRangeInfo Row(int rowIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index of the cell range. |
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
Examples
This example shows how to set the RangeInfo for specified row.
GridRangeInfo cellRange = GridRangeInfo.Row(3);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Row(3)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
Rows(Int32, Int32)
Creates a new GridRangeInfo object for the specified rows.
Declaration
public static GridRangeInfo Rows(int top, int bottom)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | top | The top row index of the cell range. |
System.Int32 | bottom | The bottom row index of the cell range. |
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
Examples
This example shows how to set the RangeInfo for specified rows.
GridRangeInfo cellRange = GridRangeInfo.Rows(3, 4);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Rows(3, 4)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
Table()
Creates a new GridRangeInfo object for the whole table.
Declaration
public static GridRangeInfo Table()
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
ToString()
Converts the attributes of this GridRangeInfo to a human-readable string.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string that contains the column and row index of the top-left and bottom-right position of this GridRangeInfo. |
Overrides
Remarks
The generate string will be in the format R#C#, R#, C#, T.
An example for a range of cells is "R1C1:R10C20" or "R5C5".
An example for a range of rows is "R1:R10" or "R6".
An example for a range of columns is "C1:C10" or "C7".
An example for a table range is "T".
ToString(IFormatProvider)
Converts the attributes of this GridRangeInfo to a human-readable string.
Declaration
public string ToString(IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
System.IFormatProvider | provider | The System.IFormatProvider to use to format the value. Is ignored. |
Returns
Type | Description |
---|---|
System.String | A string that contains the column and row index of the top-left and bottom-right position of this GridRangeInfo. |
ToString(String)
Converts the attributes of this GridRangeInfo to a human-readable string.
Declaration
public string ToString(string format)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | The parameter ignored. |
Returns
Type | Description |
---|---|
System.String | A string that contains the column and row index of the top-left and bottom-right position of this GridRangeInfo. |
ToString(String, IFormatProvider)
Converts the attributes of this GridRangeInfo to a human-readable string.
Declaration
public string ToString(string format, IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | The parameter ignored. |
System.IFormatProvider | formatProvider | The System.IFormatProvider to use to format the value. Is ignored. |
Returns
Type | Description |
---|---|
System.String | A string that contains the column and row index of the top-left and bottom-right position of this GridRangeInfo. |
UnionRange(GridRangeInfo)
Creates a GridRangeInfo that represents the union of itself and another range.
Declaration
public GridRangeInfo UnionRange(GridRangeInfo range)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | range | A range to union. |
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
UnionRange(GridRangeInfo, GridRangeInfo)
Creates a GridRangeInfo that represents the union of two ranges.
Declaration
public static GridRangeInfo UnionRange(GridRangeInfo r1, GridRangeInfo r2)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | r1 | A range to union. |
GridRangeInfo | r2 | A range to union with previous range. |
Returns
Type | Description |
---|---|
GridRangeInfo | The new GridRangeInfo that this method creates. |
Operators
Equality(GridRangeInfo, GridRangeInfo)
Determines whether the given GridRangeInfo objects are equivalent.
Declaration
public static bool operator ==(GridRangeInfo r1, GridRangeInfo r2)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | r1 | First GridRangeInfo object to compare. |
GridRangeInfo | r2 | Second GridRangeInfo object to compare. |
Returns
Type | Description |
---|---|
System.Boolean | True if they are equivalent; False otherwise. |
Inequality(GridRangeInfo, GridRangeInfo)
Determines whether the specified GridRangeInfo objects are not equivalent.
Declaration
public static bool operator !=(GridRangeInfo r1, GridRangeInfo r2)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | r1 | First GridRangeInfo object to compare. |
GridRangeInfo | r2 | Second GridRangeInfo object to compare. |
Returns
Type | Description |
---|---|
System.Boolean | True if they are not equivalent; False otherwise. |