Interface

# GridDataSource

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Provides method signatures required for the `DesktopGrid</api/user_interface/desktop/desktopgrid>` control to request and receive cell data from a data source.

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                                      | Parameters                                                                              | Returns                                                          | Shared |
|---------------------------------------------------------------------------|-----------------------------------------------------------------------------------------|------------------------------------------------------------------|--------|
| `CellAt<griddatasource.cellat>`                                           | row As `Integer</api/data_types/integer>`, column As `Integer</api/data_types/integer>` | `DesktopContainer</api/user_interface/desktop/desktopcontainer>` |        |
| `ColumnCount<griddatasource.columncount>`                                 |                                                                                         | `Integer</api/data_types/integer>`                               |        |
| `PaintHeaderContentForColumn<griddatasource.paintheadercontentforcolumn>` | g As `Graphics</api/graphics/graphics>`, column As `Integer</api/data_types/integer>`   | `Boolean</api/data_types/boolean>`                               |        |
| `PaintHeaderContentForRow<griddatasource.paintheadercontentforrow>`       | g As `Graphics</api/graphics/graphics>`, row As `Integer</api/data_types/integer>`      | `Boolean</api/data_types/boolean>`                               |        |
| `RowCount<griddatasource.rowcount>`                                       |                                                                                         | `Integer</api/data_types/integer>`                               |        |
| `RowHeight<griddatasource.rowheight>`                                     |                                                                                         | `Integer</api/data_types/integer>`                               |        |
| `WidthForColumn<griddatasource.widthforcolumn>`                           | column As `Integer</api/data_types/integer>`                                            | `Integer</api/data_types/integer>`                               |        |

## Method descriptions

<div id="griddatasource.cellat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

GridDataSource.CellAt

**CellAt**(row As `Integer</api/data_types/integer>`, column As `Integer</api/data_types/integer>`) As `DesktopContainer</api/user_interface/desktop/desktopcontainer>`

> Return a `DesktopContainer</api/user_interface/desktop/desktopcontainer>` populated with the appropriate data for the *row* and *column* passed.

<div id="griddatasource.columncount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

GridDataSource.ColumnCount

**ColumnCount** As `Integer</api/data_types/integer>`

> Return the number of columns the `DesktopGrid</api/user_interface/desktop/desktopgrid>` will display.

<div id="griddatasource.paintheadercontentforcolumn">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

GridDataSource.PaintHeaderContentForColumn

**PaintHeaderContentForColumn**(g As `Graphics</api/graphics/graphics>`, column As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

> To handle drawing the column header for the *column* passed, draw to *g* parameter passed and return `True</api/language/true>` to indicate your handled the drawing.

<div id="griddatasource.paintheadercontentforrow">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

GridDataSource.PaintHeaderContentForRow

**PaintHeaderContentForRow**(g As `Graphics</api/graphics/graphics>`, row As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

> To handle drawing the row header for the *row* passed, draw to *g* parameter passed and return `True</api/language/true>` to indicate your handled the drawing.

<div id="griddatasource.rowcount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

GridDataSource.RowCount

**RowCount** As `Integer</api/data_types/integer>`

> Return the number of rows the `DesktopGrid</api/user_interface/desktop/desktopgrid>` will display.

<div id="griddatasource.rowheight">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

GridDataSource.RowHeight

**RowHeight** As `Integer</api/data_types/integer>`

> Return the height of a single row.

<div id="griddatasource.widthforcolumn">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

GridDataSource.WidthForColumn

**WidthForColumn**(column As `Integer</api/data_types/integer>`) As `Integer</api/data_types/integer>`

> Return the width of the *column* passed.

## Notes

In order for a <span class="title-ref">DesktopGrid</span> control to be capable of displaying a virtually unlimited number of cells, it must load data into these cells dynamically when the control is initially drawn, as the user scrolls and as code executes that changes which cells are displayed. This is done by having an instance of a class that implements the <span class="title-ref">GridDataSource</span> interface. This instance will then be called by the <span class="title-ref">DesktopGrid</span> control via the methods defined by the interface which then takes requests for cells from the <span class="title-ref">DesktopGrid</span> control and returns the data from the ultimate source (a database or some other source) allowing the <span class="title-ref">DesktopGrid</span> to populate its cells.

To implement this interface:

1.  Choose an existing class such as the `DesktopWindow</api/user_interface/desktop/desktopwindow>` or `DesktopContainer</api/user_interface/desktop/desktopcontainer>` the <span class="title-ref">DesktopGrid</span> is on or add a new class to your project.
2.  In the Inspector, click the **Interfaces** button then in the Interfaces dialog box that appears, click the checkbox next to <span class="title-ref">GridDataSource</span> to select it.
3.  In the Interfaces dialog box, click the **OK** button to select the interface for the class.
4.  This will add the methods to your class that will be called when the <span class="title-ref">DesktopGrid</span> need data.

Typically in the `Opening<desktopgrid.opening>` of the <span class="title-ref">DesktopGrid</span> you would then assign the instance of class that is implementing the <span class="title-ref">GridDataSource</span> to the `DataSource<desktopgrid.datasource>` property of the <span class="title-ref">DesktopGrid</span> control.

## Compatibility

|                       |         |
|-----------------------|---------|
| **Project Types**     | Desktop |
| **Operating Systems** | All     |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `DesktopGrid</api/user_interface/desktop/desktopgrid>` class, DesktopGrid with Database Example project

</div>
