DataGrid Control

A data grid control displays data in a series of rows and columns.

Client support

   Newlook Smartclient

   Newlook Server

Use

A data grid control is automatically generated in a form whenever Newlook receives a subfile from the host. It is also possible to create a custom data grid control in Designer or dynamically via a script or macro. Custom data grids can be bound to an external data source or populated manually using one or several data grid methods.

Host generated data grids

When a subfile is received from the host, the Newlook recognition engine attempts to organize its data into columns. It does so by analyzing the relative placement of data and attribute bytes within the subfile. If columns can be clearly identified in the subfile then the ShowColumns property defaults to True and column separators are displayed in the GUI. The resulting columns are represented by the Columns collection. It is possible to reorder columns, change the visibility of columns and add new columns to a host-generated grid. It is not possible to delete any host columns however.

When the recognition engine encounters ambiguities in column recognition, the ShowColumns property defaults to False and columns will not be displayed. Despite this, the recognition engine will attempt to populate the Columns collection with data that most closely represents a logical grid structure, and even though columns are not displayed by default, it is possible to force columns to display by overriding the ShowColumns property to True, either in Designer or via a script or macro. When column recognition is forced on, the recognition engine inserts blank cells, where necessary, to organize the data into logical columns, and maintain grid headings.

When a data grid control is generated from a host subfile, there may be a difference between the total number of identified columns (which is returned by App.ActiveForm.grid.Columns.Count), and the total number of columns displayed in the GUI. This is due to the fact that Newlook will hide certain columns where it determines that these columns are not valid data columns. The columns by default have their Visible property set to False. For this reason it is important to use the count property to determine the total number of columns in a subfile before creating any code that references specific columns or contains looping structures.

It is also worth noting that each row in a data grid control may contain a different number of cells, therefore if you need to return the total number of cells in a specific row, then the grid.ColCount(RowIndex) property must be used. This is particularly relevant when looping through all the cells in a grid.

Inserted data grids

If the grid is bound to an external data source, it is typically bound to a single table containing no relationships. In this case, the data appears in simple rows and columns, as in a spreadsheet. The rows and columns displayed are dictated by the external data source.

It is also possible to use the AddRecord, DataBind, InsertColumn, InsertColumnArray and InsertRow methods to populate an inserted data grid.

Material skin considerations

When the material skin is enabled in your solution, data grids will be rendered with material styling. The most noticeable difference is a cleaner appearance and more spacing between elements in the grid (where possible). Entry capable cells will render with an underline when given focus.

Material skin

Classic skin

See Also

Columns Collection | Column Object | Cell Object | DataGrid keyboard shortcuts | Auto-hide option column | Auto-fit columns to full grid width | Allow column sorting by default | Auto-detect grid columns | Subfile recognition rules


© 2004-2021 looksoftware. All rights reserved.