Class SFTable
Implements a two-dimensional table that holds an SFArrayList of rows. Each row is an SFArrayList of objects.
Implements
Inherited Members
Namespace: Syncfusion.Collections
Assembly: Syncfusion.Shared.Base.dll
Syntax
public class SFTable : ICloneable, ISerializable
Remarks
This is a memory efficient way to represent a table where values can remain empty. Only rows that actually contain data will allocate an SFArrayList and the array only holds as many objects as the specific row contains columns.
When you access data that are out of range, an empty () object will be returned. If you set data that are out of range, an exception will be thrown. If you set data for a row that is empty, the row will be allocated before the value is stored.
SFTable provides methods that let you insert, remove or rearrange columns or rows in the table.
Constructors
SFTable()
Initializes a new instance of the SFTable class that is empty.
Declaration
public SFTable()
SFTable(SFTable, Boolean)
Initializes a new instance of the SFTable class and optional copies of data from an existing table.
Declaration
protected SFTable(SFTable data, bool clone)
Parameters
Type | Name | Description |
---|---|---|
SFTable | data | |
System.Boolean | clone |
SFTable(SerializationInfo, StreamingContext)
Initializes a new instance of the SFTable class from the specified instances of the System.Runtime.Serialization.SerializationInfo and System.Runtime.Serialization.StreamingContext classes.
Declaration
protected SFTable(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.Serialization.SerializationInfo | info | An instance of the System.Runtime.Serialization.SerializationInfo class containing the information required to serialize the new SFTable instance. |
System.Runtime.Serialization.StreamingContext | context | An instance of the System.Runtime.Serialization.StreamingContext class containing the source of the serialized stream associated with the new SFTable instance. |
Remarks
This constructor implements the System.Runtime.Serialization.ISerializable interface for the SFTable class.
Properties
ColCount
Gets / sets the number of columns contained in the SFTable.
Declaration
public int ColCount { get; set; }
Property Value
Type |
---|
System.Int32 |
Remarks
If you decrease the column count, the last columns in each row will be removed.
Item[Int32, Int32]
Gets / sets an element at the specified coordinates in the SFTable.
Declaration
public object this[int rowIndex, int colIndex] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The zero-based row index. |
System.Int32 | colIndex | The zero-based column index. |
Property Value
Type |
---|
System.Object |
Remarks
If you query for an element and the coordinates are out of range, an empty (null) object will be returned.
If you set an element and the the coordinates are out of range, an exception is thrown.
RowCount
Gets / sets the number of rows contained in the SFTable.
Declaration
public int RowCount { get; set; }
Property Value
Type |
---|
System.Int32 |
Remarks
If you decrease the row count, the rows in the SFTable will be removed.
Rows
Returns the SFArrayList from all rows.
Declaration
public SFArrayList Rows { get; }
Property Value
Type |
---|
SFArrayList |
Methods
Clear()
Removes all elements from the SFTable.
Declaration
public void Clear()
Clone()
Creates a deep copy of the SFTable.
Declaration
public virtual object Clone()
Returns
Type | Description |
---|---|
System.Object | A deep copy of the SFTable. |
Contains(Int32, Int32)
Indicates whether an element is at the specified coordinates in the SFTable.
Declaration
public bool Contains(int rowIndex, int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The zero-based row index. |
System.Int32 | colIndex | The zero-based column index. |
Returns
Type | Description |
---|---|
System.Boolean | true if an element exists at the specified coordinates in the SFTable; false otherwise. |
CreateCellCollection()
Creates a collection of cells for a row.
Declaration
public virtual SFArrayList CreateCellCollection()
Returns
Type | Description |
---|---|
SFArrayList | An SFArrayList or derived object for the cell collection. |
GetObjectData(SerializationInfo, StreamingContext)
Implements the ISerializable interface and returns the data needed to serialize the SFTable.
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. |
InsertCols(Int32, Int32)
Inserts a specified number of empty columns for each row in the SFTable at a given column index.
Declaration
public bool InsertCols(int colIndex, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | colIndex | The zero-based column index of the first column to be inserted. |
System.Int32 | count | The number of columns to be inserted. |
Returns
Type | Description |
---|---|
System.Boolean | not used. |
InsertRows(Int32, Int32)
Inserts a specified number of empty rows in the SFTable at a given row index.
Declaration
public bool InsertRows(int rowIndex, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The zero-based row index of the first row to be inserted. |
System.Int32 | count | The number of rows to be added. |
Returns
Type | Description |
---|---|
System.Boolean | not used. |
MoveCols(Int32, Int32, Int32)
Rearranges columns in the SFTable.
Declaration
public bool MoveCols(int colIndex, int count, int target)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | colIndex | The zero-based index of the first column to be moved. |
System.Int32 | count | The number of columns in the range to be moved. |
System.Int32 | target | The new starting index for the range. The zero-based index is based on the original array. |
Returns
Type |
---|
System.Boolean |
Examples
SFTable array = new SFTable();
array.ColCount = 5;
array.RowCount = 1;
array[0,0] = 0;
array[0,1] = 1;
array[0,2] = 2;
array[0,3] = 3;
array.MoveCols(0, 2, 3);
// results in new order: 2, 0, 1, 3
MoveRows(Int32, Int32, Int32)
Rearranges rows in the SFTable.
Declaration
public bool MoveRows(int rowIndex, int count, int target)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The zero-based index of the first row to be moved. |
System.Int32 | count | The number of rows in the range to be moved. |
System.Int32 | target | The new starting index for the range. The zero-based index is based on the original array. |
Returns
Type |
---|
System.Boolean |
Examples
SFTable array = new SFTable();
array.RowCount = 5;
array.ColCount = 1;
array[0,0] = 0;
array[1,0] = 1;
array[2,0] = 2;
array[3,0] = 3;
array.MoveRows(0, 2, 3);
// results in new order: 2, 0, 1, 3
RemoveCols(Int32, Int32)
Removes a specified number of columns for each row in the SFTable at a given column index.
Declaration
public bool RemoveCols(int colIndex, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | colIndex | The zero-based column index of the first column to be removed. |
System.Int32 | count | The number of columns to be removed. |
Returns
Type | Description |
---|---|
System.Boolean | not used. |
RemoveRows(Int32, Int32)
Removes a specified number of rows from the SFTable at a given row index.
Declaration
public bool RemoveRows(int rowIndex, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The zero-based row index of the first row to be removed. |
System.Int32 | count | The number of rows to be removed. |
Returns
Type | Description |
---|---|
System.Boolean | not used. |