Skip to main content

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.

ParameterTypeDescription
widthintwidth
rowHeightintrowHeight
rowCountintrowCount
fontFontfont

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.

ParameterTypeDescription
senderobjectObject associated with this event.
argsTapCellEventArgsTap 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.

ParameterTypeDescription
eTouchEventArgsTouch event arguments.

OnTouchUp(TouchEventArgs e)​

protected override void OnTouchUp(TouchEventArgs e)

Handles the touch up event.

ParameterTypeDescription
eTouchEventArgsTouch event arguments.

OnTouchMove(TouchEventArgs e)​

protected override void OnTouchMove(TouchEventArgs e)

Handles the touch move event.

ParameterTypeDescription
eTouchEventArgsTouch event arguments.

AddColumn(DataGridColumn dataGridColumn)​

public void AddColumn(DataGridColumn dataGridColumn)

Adds a column.

ParameterTypeDescription
dataGridColumnDataGridColumndataGridColumn

AddColumnAt(int index, DataGridColumn dataGridColumn)​

public void AddColumnAt(int index, DataGridColumn dataGridColumn)

Adds a column at a specified index.

ParameterTypeDescription
indexintindex
dataGridColumnDataGridColumndataGridColumn

RemoveColumn(DataGridColumn dataGridColumn)​

public void RemoveColumn(DataGridColumn dataGridColumn)

Removes a column.

ParameterTypeDescription
dataGridColumnDataGridColumndataGridColumn

RemoveColumnAt(int index)​

public void RemoveColumnAt(int index)

Removes a column at a specified index.

ParameterTypeDescription
indexintindex

AddItem(DataGridItem dataGridItem)​

public void AddItem(DataGridItem dataGridItem)

Adds an item.

ParameterTypeDescription
dataGridItemDataGridItemdataGridItem

AddItemAt(int index, DataGridItem dataGridItem)​

public void AddItemAt(int index, DataGridItem dataGridItem)

Adds an item at a specified index.

ParameterTypeDescription
indexintindex
dataGridItemDataGridItemdataGridItem

RemoveItem(DataGridItem dataGridItem)​

public void RemoveItem(DataGridItem dataGridItem)

Removes an item.

ParameterTypeDescription
dataGridItemDataGridItemdataGridItem

RemoveItemAt(int index)​

public void RemoveItemAt(int index)

Removes an item a specified index.

ParameterTypeDescription
indexintindex

ScrollUp(int amount)​

public void ScrollUp(int amount)

Scroll the rows up by a specified amount.

ParameterTypeDescription
amountintamount

ScrollDown(int amount)​

public void ScrollDown(int amount)

Scroll the rows down by a specified amount.

ParameterTypeDescription
amountintamount

ScrollTo(int index)​

public void ScrollTo(int index)

Scroll the rows to a specified index.

ParameterTypeDescription
indexintindex

SetRowData(int index, object[] data)​

public void SetRowData(int index, object[] data)

Sets new row data.

ParameterTypeDescription
indexintindex
dataobject[]Data object array.

GetRowData(int index)​

public object[] GetRowData(int index)

Gets row data.

ParameterTypeDescription
indexintindex

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.

ParameterTypeDescription
columnIndexintcolumnIndex
rowIndexintrowIndex
dataobjectdata

GetCellData(int columnIndex, int rowIndex)​

public object GetCellData(int columnIndex, int rowIndex)

Get a cell's data.

ParameterTypeDescription
columnIndexintcolumnIndex
rowIndexintrowIndex

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.