0

I have problem with DevExpress XtraGrid. I wont to make a column of CheckedComboBoxEdit's, but i dont know how to make them work separately. For example, in first row my CheckedComboBoxEdit will contain "a" and "b", and in second "b", "c", "d".

I thought i can use sth like this:

    List<CheckedListBoxItem> listOfCheckedItems = new List<CheckedListBoxItem>();
    listOfCheckedItems.Add( new CheckedListBoxItem( "test" ) );
    CheckedComboBoxEdit checkedCombo = new CheckedComboBoxEdit();
    gridView1.AddNewRow();
    gridView1.SetRowCellValue( gridView1.RowCount - 1, gridView1.Columns[ 1 ], checkedCombo );

Where: gridView1 is MainView of my gridControl.

Fils
  • 47
  • 5

1 Answers1

1

You can use ColumnView.ShownEditor event and ColumnView.FocusedRowHandle and ColumnView.FocusedColumn and ColumnView.ActiveEditor properties.
Here is example:

private void gridView1_ShownEditor(object sender, EventArgs e)
{
    if (gridView1.FocusedColumn.FieldName != "YourCheckedComboBoxColumn")
        return;

    var editor = (CheckedComboBoxEdit)gridView1.ActiveEditor;
    editor.Properties.Items.Clear();

    var value = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "YourEyeColumn").ToString();

    if (value == "Eye Color")
        editor.Properties.Items.AddRange(new CheckedListBoxItem[] { new CheckedListBoxItem("Green"), new CheckedListBoxItem("Blue"), new CheckedListBoxItem("Grey") });
    else if (value == "Eye Size")
        editor.Properties.Items.AddRange(new CheckedListBoxItem[] { new CheckedListBoxItem("Big"), new CheckedListBoxItem("Medium"), new CheckedListBoxItem("Small") });
}
nempoBu4
  • 6,521
  • 8
  • 35
  • 40
  • Thanks for help, but unfortunately, its doesnt work for me. cells doesnt change after this event. Is there any other possibilities to make it? I just wont to make grid like this: For example: row 1) "Eye Color" | CheckComboBoxEdit with "Green", "Blue", "Grey" row 2) "Eye Size" | CheckComboBoxEdit with "Big", "Medium", "Small" and so on. – Fils Sep 02 '14 at 11:03
  • 1
    @Fils You can use [`GridView.GetRowCellValue`](https://documentation.devexpress.com/#windowsforms/DevExpressXtraGridViewsGridGridView_GetRowCellValuetopic) method. I have updated my answer. – nempoBu4 Sep 02 '14 at 11:38
  • Thanks for help, it's works great for ComboBoxEdit (which i decided to use), but still i have problem to update CheckComboBoxEdit - its just dosent wont to update. With ComboBoxEdit and others controls I dont have this problem, strange. One more time: thanks for help. – Fils Sep 02 '14 at 11:51