Skip to main content
A newer version of this page is available. .

RowProperties.UnboundType Property

Gets or sets the data type and binding mode of the row.

Namespace: DevExpress.XtraVerticalGrid.Rows

Assembly: DevExpress.XtraVerticalGrid.v19.1.dll

Declaration

[DefaultValue(UnboundColumnType.Bound)]
[XtraSerializableProperty]
public virtual UnboundColumnType UnboundType { get; set; }

Property Value

Type Default Description
UnboundColumnType **Bound**

A UnboundColumnType enumeration value representing the data type and binding mode of the row.

Available values:

Name Description
Bound

Indicates that the column is bound to a field in the control’s underlying data source. The type of data this column contains is determined by the bound field.

Integer

Indicates that the column is unbound and it contains integer values (the Int32 type).

Decimal

Indicates that the column is unbound and it contains decimal values (the Decimal type).

DateTime

Indicates that the column is unbound and it contains date/time values (the DateTime type).

String

Indicates that the column is unbound and it contains string values (the String type).

Boolean

Indicates that the column is unbound and it contains Boolean values (the Boolean type).

Object

Indicates that the column is unbound and it contains values of any type. A TextEdit editor is assigned for the in-place editing of such a column.

Remarks

The Vertical Grid Control supports unbound rows. These are rows which aren’t bound to any field in the grid’s data source, which is specified by the VGridControl.DataSource and VGridControl.DataMember properties. Data for unbound rows should be supplied using one of two methods:

  • setting a formula (string expression) to the RowProperties.UnboundExpression property. In expressions, you can refer to other fields, and use various functions and operators. See Expressions, to learn about the syntax.
  • handling the VGridControl.CustomUnboundData event. This event can also be used to save any changes made by an end-user in unbound rows via the grid.

To make a row unbound, set its UnboundType property to a UnboundColumnType value that corresponds to the type of data the row will display. For example, if the row is supposed to display integer values, set the UnboundType property to UnboundColumnType.Integer. The data type specified by the UnboundType property determines which editor should be used by default, to edit the row’s values. In addition, it also determines how values are aligned within the row, and which validity rules should be applied to this row. See the UnboundColumnType topic, for information on the available data types for unbound rows.

If the row’s UnboundType property is set to UnboundColumnType.Bound, it’s assumed that this row is not unbound, and it is bound to a specific field in the data source, specified by the RowProperties.FieldName property.

Example

Assume that a VGridControl control is bound to the [Order Details] table in the NWind database. The grid contains “Quantity”, “UnitPrice” and “Discount” rows which are bound to the corresponding fields in the database table. The example below shows how to add an unbound row to the grid, to display the amount of each order according to the expression: QuantityUnitPrice(1-Discount).

The result is displayed below:

VGridControl_UnboundRow_ex

using DevExpress.XtraVerticalGrid;
using DevExpress.XtraVerticalGrid.Rows;
using DevExpress.Data;
using DevExpress.Utils;
using DevExpress.XtraVerticalGrid.Events;

// Unbound row.
EditorRow rowTotal = null;

private void Form1_Load(object sender, EventArgs e) {
    // ...
    vGridControl1.CustomUnboundData += new CustomDataEventHandler(vGridControl1_CustomUnboundData);
    // Create and initialize the unbound Total row.
    rowTotal = new EditorRow();
    rowTotal.Properties.Caption = "Total";
    rowTotal.Properties.FieldName = "Total";
    // Specify format settings.
    rowTotal.Properties.Format.FormatType = FormatType.Numeric;
    rowTotal.Properties.Format.FormatString = "c";            
    rowTotal.Properties.ImageIndex = 1;
    // Disable editing.
    rowTotal.Properties.ReadOnly = true;            
    vGridControl1.Rows.Add(rowTotal);
    rowTotal.Properties.UnboundType = UnboundColumnType.Decimal;
    // Customize the appearance settings.
    rowTotal.Appearance.BackColor = Color.LightYellow;
    rowTotal.Appearance.Font = new System.Drawing.Font(rowTotal.Appearance.Font, 
        System.Drawing.FontStyle.Bold);
}

// Provide data for the Total row.
private void vGridControl1_CustomUnboundData(object sender, CustomDataEventArgs e) {
    VGridControl vGrid = sender as VGridControl;
    if (e.Row == rowTotal && e.IsGetData) {
        DataRowView row = (DataRowView)vGrid.GetRecordObject(e.ListSourceRowIndex);
        decimal unitPrice = Convert.ToDecimal(row["UnitPrice"]);
        decimal quantity = Convert.ToDecimal(row["Quantity"]);
        decimal discount = Convert.ToDecimal(row["Discount"]); ;
        e.Value = unitPrice * quantity * (1 - discount);
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the UnboundType property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also