PageDataGridUISetColumn Event |
Namespace: SOWIWin.Helper
//* 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; }