Editor Rows
- 4 minutes to read
The vertical grid controls (VGridControl and PropertyGridControl) provide three different types of rows to allow data to be represented in the most appropriate way. These different row types are all covered in brief in the Rows Overview topic. This topic describes the features provided by editor rows.
Editor Rows
Editor rows are the most used row type. They are capable of displaying header and data cells - a single cell in each record. If in bound mode editor rows display the values of the fields in the underlying dataset. If in Unbound Mode such rows will display the caption and a single data cell. Thus, editor rows are just the same as columns in standard (horizontal) grid controls - the basic building blocks of data representation.
The image below shows the editor rows.
As with rows of other types, editor rows can be the parents or children of other rows thus forming a hierarchical data structure within a vertical grid. Please refer to the Creating a Tree-Like Structure of Rows topic for details.
Features of Editor Rows
Editor rows have two sets of settings that affect their appearance and functionality. The first set is common to all rows and is represented by properties inherited from the BaseRow class. These properties specify the expanded state, row height, options, appearance of data cells and visibility.
The second set of settings is represented by the row item settings object which is returned by the EditorRow.Properties property. Since editor rows are capable of displaying the values in a single field, these settings enable you to specify the header’s appearance, a set of attributes which affect data binding and the manner in which values are displayed and edited. These properties are listed below:
Row Header Settings
- The row header’s caption - the RowProperties.Caption property.
- The index of the image displayed within a row header - the RowProperties.ImageIndex property.
Data Settings
- The name of the bound data field - the RowProperties.FieldName property. (This isn’t used in Unbound Mode).
- The format of the values displayed within data cells - the RowProperties.Format property (the FormatInfo.FormatType and FormatInfo.FormatString properties). See the Formatting Values topic for details.
- The read-only state of data cells - the RowProperties.ReadOnly property.
- The editor used to display and edit cell values - the RowProperties.RowEdit property. Refer to the Assigning Editors to Editor Rows topic for details.
- The value stored in a row cell (used in Unbound Mode only) - the RowProperties.Value property.
The image below illustrates an editor row’s settings.
The BaseRow.Appearance property provides the appearance settings used to paint data cells.
Customizing Editor Rows at Runtime
The following code customizes the editor used for the Price field, its height, appearance, header image and the formatting applied to cell values.
The image below shows the result.
using DevExpress.XtraVerticalGrid;
using DevExpress.XtraVerticalGrid.Rows;
// ...
// obtaining the row
EditorRow row = vGridControl1.Rows["rowPrice"] as EditorRow;
// modifying the height
row.Height = 30;
// changing the row's appearance settings
row.Appearance.BackColor = Color.FromArgb(227, 240, 255);
row.Appearance.BackColor2 = Color.Yellow;
// displaying an image within the header
ImageList images = new ImageList();
images.Images.Add(Image.FromFile("e:\\Images\\Icons\\currency.bmp"));
vGridControl1.ImageList = images;
row.Properties.ImageIndex = 0;
// applying currency formatting to the row's values
row.Properties.Format.FormatType = FormatType.Numeric;
row.Properties.Format.FormatString = "c0";
// assigning a spin editor to the row
row.Properties.RowEdit = vGridControl1.RepositoryItems.Add("SpinEdit");