Struct GridCell
- Namespace
- SharpConsoleUI.Controls
- Assembly
- SharpConsoleUI.dll
A lightweight value-type handle to a single cell of a GridControl, addressed by its
top-left row and column. It is not a control and is not stored in the grid: it holds only the grid
reference plus the cell coordinate, and every member reads or writes the grid's cell store directly.
Obtain one from the grid's indexer (grid[row, col]) or Cell(int, int).
public readonly struct GridCell
- Inherited Members
- Extension Methods
Remarks
Because the struct is a transient handle, its setters mutate the grid (not the struct), so writing through a copied handle still affects the grid. Styling data lives on the cell's GridPlacement, which lets an empty cell be styled before it is filled.
Properties
Background
Gets or sets this cell's background fill colour. null means no per-cell background (the
cell shows through). Setting null via this property is a no-op (it leaves the current
value unchanged); use ResetStyle() to clear the cell's styling while keeping its
content, or Clear() to drop the cell's content entirely.
public Color? Background { get; set; }
Property Value
Border
Gets or sets this cell's border style. Defaults to None. A non-None border draws a one-cell box around the cell and insets its content by one cell on every side.
public BorderStyle Border { get; set; }
Property Value
Col
Gets the zero-based column index of this cell's top-left corner.
public int Col { get; }
Property Value
Content
Gets or sets the control placed in this cell. Getting returns the cell's control or null
when the cell is empty (or styled-but-content-less). Setting to a control places/replaces it
(keeping any per-cell styling); setting to null clears the content.
public IWindowControl? Content { get; set; }
Property Value
IsEmpty
Gets whether this cell currently holds no content. A styled-but-empty cell still reports
true here (it has chrome but no control).
public bool IsEmpty { get; }
Property Value
Padding
Gets or sets the padding that insets this cell's content from the cell edges (or from the inside of the border when Border is set). Defaults to None.
public Padding Padding { get; set; }
Property Value
Placement
Gets the full GridPlacement of this cell (position, spans, and styling), or
null when the cell has neither content nor styling.
public GridPlacement? Placement { get; }
Property Value
Row
Gets the zero-based row index of this cell's top-left corner.
public int Row { get; }
Property Value
Methods
Clear()
Clears this cell's content. Equivalent to setting Content to null.
public void Clear()
ResetStyle()
Clears this cell's per-cell styling — background, border and padding — while keeping its
content. This is the explicit way to remove styling, since setting Background to
null is a no-op. When the cell is content-less (a styled empty cell), resetting leaves it
with neither content nor style, so the cell is removed entirely.
public void ResetStyle()