windowsforms-devexpress-dot-xtraverticalgrid-dot-rows-dot-rowproperties-3864c4b3.md
Allows you to make the row unbound, and specify the type of data it stores.
Namespace : DevExpress.XtraVerticalGrid.Rows
Assembly : DevExpress.XtraVerticalGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid
[DXCategory("Data")]
public Type UnboundDataType { get; set; }
<DXCategory("Data")>
Public Property UnboundDataType As Type
| Type | Description |
|---|---|
| Type |
The type of data to store in the unbound row.
|
If the UnboundDataType property is not set to a valid data type (the property’s default value is System.Void ), the current row is considered bound to a data source field (RowProperties.FieldName).
To switch a row to unbound mode, do the following:
See the following help topic for more information: Unbound Rows.
In the following example, it is assumed that the Vertical Grid is bound to a table that contains the “Quantity”, “UnitPrice” and “Discount” fields. The code below adds an unbound row that calculates the total order amount according to the following expression: Quantity*UnitPrice*(1-Discount).
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";
// Disable edit operations.
rowTotal.Properties.ReadOnly = true;
vGridControl1.Rows.Add(rowTotal);
rowTotal.Properties.UnboundDataType = typeof(decimal);
// Customize the appearance settings.
rowTotal.Appearance.BackColor = Color.FromArgb(179, 226, 221);
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);
}
}
Imports DevExpress.XtraVerticalGrid
Imports DevExpress.XtraVerticalGrid.Rows
Imports DevExpress.Data
Imports DevExpress.Utils
Imports DevExpress.XtraVerticalGrid.Events
' Unbound row.
Dim rowTotal As EditorRow
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'...
AddHandler VGridControl1.CustomUnboundData, AddressOf 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"
' Disable edit operations.
rowTotal.Properties.ReadOnly = True
VGridControl1.Rows.Add(rowTotal)
rowTotal.Properties.UnboundDataType = GetType(Decimal)
' Customize the appearance settings.
rowTotal.Appearance.BackColor = Color.FromArgb(179, 226, 221)
rowTotal.Appearance.Font = New System.Drawing.Font(rowTotal.Appearance.Font, _
System.Drawing.FontStyle.Bold)
End Sub
' Provide data for the Total row.
Private Sub VGridControl1_CustomUnboundData(ByVal sender As System.Object, _
ByVal e As CustomDataEventArgs)
Dim vGrid As VGridControl = sender
If e.Row Is rowTotal And e.IsGetData Then
Dim row As DataRowView = vGrid.GetRecordObject(e.ListSourceRowIndex)
Dim unitPrice As Decimal = Convert.ToDecimal(row("UnitPrice"))
Dim quantity As Decimal = Convert.ToDecimal(row("Quantity"))
Dim discount As Decimal = Convert.ToDecimal(row("Discount"))
e.Value = unitPrice * quantity * (1 - discount)
End If
End Sub
See Also