Click or drag to resize

PageDataGridUISetColumn Event

Event handler for change or cancel the column being created

Namespace:  SOWIWin.Helper
Assembly:  SOWIWin.Helper (in SOWIWin.Helper.dll) Version: 19.1.23.1 (19.1.23.622)
Syntax
internal event EventHandler<DataGridAutoGeneratingColumnEventArgs> SetColumn

Value

Type: SystemEventHandlerDataGridAutoGeneratingColumnEventArgs
Remarks
This event handler called from event AutoGeneratingColumn.
Examples
This example replace column Label with a selection list (ComboBox) and puts selected value to column Value (that for better presentation)
//* change column Label with a selection list *
if (e.PropertyName.ToString() == "Label")
{
    //* create selection list *
    //* note: using Dictionary object then can uses Key and Value as field name to ComboBox object *
    //* important: property "Key" data type must the same data type to binding e.g. double *
    Dictionary<double, string> lNameList = new Dictionary<double, string>();
    lNameList.Add(1, "Label 1");
    lNameList.Add(2, "Label 2");
    lNameList.Add(3, "Label 3");

    //* create a selection list for DataGrid object (ComboBox) *
    DataGridComboBoxColumn lComboBox = new DataGridComboBoxColumn();

    //* important: puts the same property Header because follow handling e.g. read only (DataGridView) *
    lComboBox.Header = "Label";


    //* puts selection list properties *
    lComboBox.ItemsSource = lNameList;                     //* selection list *
    lComboBox.SelectedValueBinding = new Binding("Value"); //* selected value sets to DataGrid column name *
    lComboBox.SelectedValuePath = "Key";                   //* read selected value to DataGrid column name *
    lComboBox.DisplayMemberPath = "Value";                 //* which value to displayed from selection list *

    //* replace the column with this one *.
    e.Column = lComboBox;

}
See Also