GridControl.CustomUnboundColumnData Event

Enables data to be supplied to unbound columns.

Namespace: DevExpress.UI.Xaml.Grid

Assembly: DevExpress.UI.Xaml.Grid.v21.2.dll

Declaration

public event GridColumnDataEventHandler CustomUnboundColumnData

Event Data

The CustomUnboundColumnData event's data class is GridColumnDataEventArgs. The following properties provide information specific to this event:

Property Description
Column Gets the unbound column currently being processed.
ListSourceRowIndex Gets the index of the record in the data source to which the processed item corresponds.
Row Get a data row which contains the cell currently being processed.
Source Gets the grid control that raised the event.

The event data class exposes the following methods:

Method Description
GetListSourceFieldValue(Int32, String) Returns the value of the specified cell within the specified item in the grid item source.
GetListSourceFieldValue(String) Returns the value of the specified cell within the processed item in the grid item source.

Remarks

Unbound columns are not bound to any field in the data source. In most instances, data for unbound columns is obtained from a custom data source or is calculated based upon the values of bound columns. To provide data for unbound columns, handle the CustomUnboundColumnData event.

This example shows how to add an unbound column to the Grid Control.

using System;
using DevExpress.Data;
using Windows.UI.Xaml.Controls;


namespace Unbound_Columns
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            grid.ItemsSource = new ProductList();
            grid.TotalSummary.Add(SummaryItemType.Count, "ProductName");
            grid.TotalSummary.Add(SummaryItemType.Max, "UnitPrice").DisplayFormat = "Max: {0:c2}";
            grid.TotalSummary.Add(SummaryItemType.Average, "UnitPrice").DisplayFormat = "Avg: {0:c2}";
        }

        private void grid_CustomUnboundColumnData(object sender, DevExpress.UI.Xaml.Grid.GridColumnDataEventArgs e) {
            if (e.IsGetData) {
                int price = Convert.ToInt32(e.GetListSourceFieldValue("UnitPrice"));
                int quantity = Convert.ToInt32(e.GetListSourceFieldValue("Quantity"));
                e.Value = price * quantity;
            }
        }
    }
}
See Also