This documentation topic describes legacy technology. We no longer develop new functionality for the GridControl and suggest that you use the new DataGridView control instead.
The grid stores its columns in the Columns collection. This collection provides methods that allow you to add new and remove existing columns. Individual columns are specified by GridColumn descendants, and can be accessed using indexer notation or by the field name (GridColumn.FieldName). To access only columns that are currently displayed within the grid, use the GridControl.VisibleColumns property.
To learn more on grid columns, see the following topics.
This example shows how to add columns to GridControl to display and edit data of different types. The grid is bound to a collection of Employee objects. Each Employee object contains an employee's photo (image), name, position, phone, address (strings), hire and birth dates (DateTime values), a value that specifies an employee's access level, and a Boolean value indicating whether an employee is on vacation.
Grid columns are stored in the GridControl.Columns collection. An individual column is specified by a GridColumn descendant, which is appropriate to the type of data contained in this column. In this example, to display information on employees and allow end-users to edit it, the following columns are created in the grid.
A cell in this column displays three employee properties: Name, Position and HireDate. A cell appearance is defined via a template. Each cell contains three Xamarin.Forms.Label elements within a Xamarin.Forms.Grid. Each Label element is bound to a property of the Employee class.
A cell template data context is specified by the CellData object. Its CellData.Value property provides access to a value of a data field assigned to the column's GridColumn.FieldName property.
In this example, a column cell displays not only this field value but also values of two more fields. So, it is required to specify the whole data row as a binding source for the template. To do this, set the BindingContext property of the Grid to CellData.Source. Note that BindingContext specified for the Grid is inherited by all its children. This means that all Label elements have the same BindingContext as the Grid, and
you can specify their simple bindings to properties of that object (Employee).
The employee's Access property is of the AccessLevel type which is an enumeration with values Admin and User. To allow editing an employee's access level by selecting one of two enumeration values, this property is bound to the grid's picker column.
We are updating the DevExpress product documentation website and this page is part of our new experience. During this transition period, product documentation remains available in our previous format at documentation.devexpress.com. Learn More...
Was this page helpful?
Thanks for your feedback! Any other suggestions? Tell us here.