DataGrid Class
NuGet: GHIElectronics.TinyCLR.UI
Assembly: GHIElectronics.TinyCLR.UI
Namespace: GHIElectronics.TinyCLR.UI.Controls
The DataGrid component is a list-based component that provides a grid of rows and columns.
public class DataGrid : ContentControl
Constructors
DataGrid(int width, int rowHeight, int rowCount, Font font)
public DataGrid(int width, int rowHeight, int rowCount, Font font)
Creates a new DataGrid component.
| Parameter | Type | Description |
|---|---|---|
width | int | width |
rowHeight | int | rowHeight |
rowCount | int | rowCount |
font | Font | font |
Properties
RowCount
public int RowCount { get; set; }
Number of rows displayed.
Font
public new Font Font { get; set; }
Font used by the text.
RowHeight
public int RowHeight { get; set; }
Row height.
SelectedIndex
public int SelectedIndex { get; set; }
The currently selected index.
NumItems
public int NumItems { get; }
Number of items in the DataGrid.
TappableCells
public bool TappableCells { get; set; }
Indicates whether items trigger cell tap events or not.
Draggable
public bool Draggable { get; set; }
Indicates whether or not the item list can be dragged up and down.
ShowHeaders
public bool ShowHeaders { get; set; }
Indicates whether the headers are shown.
SortableHeaders
public bool SortableHeaders { get; set; }
Indicates whether the headers are sortable.
HeadersBackColor
public Media.Color HeadersBackColor { get; set; }
Headers background color.
HeadersFontColor
public Media.Color HeadersFontColor { get; set; }
Headers font color.
ItemsBackColor
public Media.Color ItemsBackColor { get; set; }
Items background color.
ItemsAltBackColor
public Media.Color ItemsAltBackColor { get; set; }
Items alternate background color.
ItemsFontColor
public Media.Color ItemsFontColor { get; set; }
Items font color.
SelectedItemBackColor
public Media.Color SelectedItemBackColor { get; set; }
Selected item background color.
SelectedItemFontColor
public Media.Color SelectedItemFontColor { get; set; }
Selected item font color.
GridColor
public Media.Color GridColor { get; set; }
Grid color.
ShowScrollbar
public bool ShowScrollbar { get; set; }
Indicates whether the scrollbar is shown.
ScrollbarWidth
public int ScrollbarWidth { get; set; }
Scrollbar width.
ScrollbarBackColor
public Media.Color ScrollbarBackColor { get; set; }
Scrollbar background color.
ScrollbarScrubberColor
public Media.Color ScrollbarScrubberColor { get; set; }
Scrollbar scrubber color.
MaxIgnoredTouchMoves
public int MaxIgnoredTouchMoves { get; set; }
Touch senstitive.
Methods
Dispose()
public void Dispose()
Releases the resources used by the DataGrid.
Dispose(bool disposing)
protected virtual void Dispose(bool disposing)
Releases the DataGrid's bitmap and icon resources.
TriggerTapCellEvent(object sender, TapCellEventArgs args)
public void TriggerTapCellEvent(object sender, TapCellEventArgs args)
Triggers a tap cell event.
| Parameter | Type | Description |
|---|---|---|
sender | object | Object associated with this event. |
args | TapCellEventArgs | Tap cell event arguments. |
OnRender(DrawingContext dc)
public override void OnRender(DrawingContext dc)
Renders the DataGrid onto it's parent container's graphics.
OnTouchDown(TouchEventArgs e)
protected override void OnTouchDown(TouchEventArgs e)
Handles the touch down event.
| Parameter | Type | Description |
|---|---|---|
e | TouchEventArgs | Touch event arguments. |
OnTouchUp(TouchEventArgs e)
protected override void OnTouchUp(TouchEventArgs e)
Handles the touch up event.
| Parameter | Type | Description |
|---|---|---|
e | TouchEventArgs | Touch event arguments. |
OnTouchMove(TouchEventArgs e)
protected override void OnTouchMove(TouchEventArgs e)
Handles the touch move event.
| Parameter | Type | Description |
|---|---|---|
e | TouchEventArgs | Touch event arguments. |
AddColumn(DataGridColumn dataGridColumn)
public void AddColumn(DataGridColumn dataGridColumn)
Adds a column.
| Parameter | Type | Description |
|---|---|---|
dataGridColumn | DataGridColumn | dataGridColumn |
AddColumnAt(int index, DataGridColumn dataGridColumn)
public void AddColumnAt(int index, DataGridColumn dataGridColumn)
Adds a column at a specified index.
| Parameter | Type | Description |
|---|---|---|
index | int | index |
dataGridColumn | DataGridColumn | dataGridColumn |
RemoveColumn(DataGridColumn dataGridColumn)
public void RemoveColumn(DataGridColumn dataGridColumn)
Removes a column.
| Parameter | Type | Description |
|---|---|---|
dataGridColumn | DataGridColumn | dataGridColumn |
RemoveColumnAt(int index)
public void RemoveColumnAt(int index)
Removes a column at a specified index.
| Parameter | Type | Description |
|---|---|---|
index | int | index |
AddItem(DataGridItem dataGridItem)
public void AddItem(DataGridItem dataGridItem)
Adds an item.
| Parameter | Type | Description |
|---|---|---|
dataGridItem | DataGridItem | dataGridItem |
AddItemAt(int index, DataGridItem dataGridItem)
public void AddItemAt(int index, DataGridItem dataGridItem)
Adds an item at a specified index.
| Parameter | Type | Description |
|---|---|---|
index | int | index |
dataGridItem | DataGridItem | dataGridItem |
RemoveItem(DataGridItem dataGridItem)
public void RemoveItem(DataGridItem dataGridItem)
Removes an item.
| Parameter | Type | Description |
|---|---|---|
dataGridItem | DataGridItem | dataGridItem |
RemoveItemAt(int index)
public void RemoveItemAt(int index)
Removes an item a specified index.
| Parameter | Type | Description |
|---|---|---|
index | int | index |
ScrollUp(int amount)
public void ScrollUp(int amount)
Scroll the rows up by a specified amount.
| Parameter | Type | Description |
|---|---|---|
amount | int | amount |
ScrollDown(int amount)
public void ScrollDown(int amount)
Scroll the rows down by a specified amount.
| Parameter | Type | Description |
|---|---|---|
amount | int | amount |
ScrollTo(int index)
public void ScrollTo(int index)
Scroll the rows to a specified index.
| Parameter | Type | Description |
|---|---|---|
index | int | index |
SetRowData(int index, object[] data)
public void SetRowData(int index, object[] data)
Sets new row data.
| Parameter | Type | Description |
|---|---|---|
index | int | index |
data | object[] | Data object array. |
GetRowData(int index)
public object[] GetRowData(int index)
Gets row data.
| Parameter | Type | Description |
|---|---|---|
index | int | index |
Returns object[] — Data object array.
SetCellData(int columnIndex, int rowIndex, object data)
public void SetCellData(int columnIndex, int rowIndex, object data)
Sets a cell's data.
| Parameter | Type | Description |
|---|---|---|
columnIndex | int | columnIndex |
rowIndex | int | rowIndex |
data | object | data |
GetCellData(int columnIndex, int rowIndex)
public object GetCellData(int columnIndex, int rowIndex)
Get a cell's data.
| Parameter | Type | Description |
|---|---|---|
columnIndex | int | columnIndex |
rowIndex | int | rowIndex |
Returns object
Sort(int columnIndex)
public void Sort(int columnIndex)
Sorts the items on a specified column index.
Clear()
public void Clear()
Clears all items including their data and resets the data grid.
Events
TapCellEvent
public event OnTapCell TapCellEvent
Tap grid event.