Class ValuesTableGrid<T>
- Namespace
- SunamoCollectionsValuesTableGrid
- Assembly
- SunamoCollectionsValuesTableGrid.dll
Represents a two-dimensional table grid that allows querying parallel collections as one. Rows represent the outer list, columns represent inner list elements. A similar class using a two-dimensional array is UniqueTableInWhole.
public class ValuesTableGrid<T> : List<List<T>>, IList<List<T>>, ICollection<List<T>>, IReadOnlyList<List<T>>, IReadOnlyCollection<List<T>>, IEnumerable<List<T>>, IList, ICollection, IEnumerable
Type Parameters
TThe type of elements in the table grid.
- Inheritance
-
ValuesTableGrid<T>
- Implements
-
ICollection<List<T>>IReadOnlyList<List<T>>IEnumerable<List<T>>
- Inherited Members
- Extension Methods
Constructors
ValuesTableGrid(List<List<T>>, bool)
Initializes a new instance of the ValuesTableGrid class.
public ValuesTableGrid(List<List<T>> rows, bool isTrimToSmallest = true)
Parameters
rowsList<List<T>>The collection of rows to initialize the grid with.
isTrimToSmallestboolIf true, trims all rows to match the smallest row count.
Properties
Captions
Gets or sets the column captions for the table grid.
public List<string> Captions { get; set; }
Property Value
Methods
IsAllInColumn(int, T)
Checks if all elements in the specified column equal the given value.
public bool IsAllInColumn(int columnIndex, T value)
Parameters
columnIndexintThe zero-based index of the column to check.
valueTThe value to compare against.
Returns
- bool
True if all elements in the column equal the value; otherwise, false.
IsAllInRow(int, T)
Checks if all elements in the specified row equal the given value.
public bool IsAllInRow(int rowIndex, T value)
Parameters
rowIndexintThe zero-based index of the row to check.
valueTThe value to compare against.
Returns
- bool
True if all elements in the row equal the value; otherwise, false.
SwitchRowsAndColumn()
Switches rows and columns to create a transposed DataTable. The Captions property must be initialized before calling this method. All row values must not contain carriage return or newline characters.
public DataTable SwitchRowsAndColumn()
Returns
- DataTable
A DataTable with rows and columns switched.
ToDataTable()
Converts the grid data to a DataTable with captions as the first row.
public DataTable? ToDataTable()
Returns
- DataTable
A DataTable representing the grid data, or null if validation fails.