Reputation: 149
There is a strange behavior when using a ComboBox in VGridControl.
I have a list of objects:
var samples = new List<Samples>();
samples.Add(new Samples {Id = 1, Name = "s1"});
samples.Add(new Samples {Id = 2, Name = "s2"});
samples.Add(new Samples {Id = 3, Name = "s3"});
samples.Add(new Samples {Id = 4, Name = "s4"});
VGridControl has one row, and this row has a RowEdit = CheckedComboBoxEdit.
CheckedComboBoxEdit.ShowDropDown is set to "DoubleClick".
Then:
repositoryItemCheckedComboBoxEdit1.DataSource = samples;
repositoryItemCheckedComboBoxEdit1.ValueMember = "Id";
repositoryItemCheckedComboBoxEdit1.DisplayMember = "Name";
row.Properties.Value = "2, 4";
Repro steps:
When I press the drop down button and then check the CheckedState for each item - it's OK. It shows the correct values;
When I simply select the row (press the row itself) and do not expand the drop down list, then CheckedState of all items is "Unchecked".
I check using:
int checkedItems = 0;
foreach (var item in repositoryItemCheckedComboBoxEdit1.GetItems().Cast<CheckedListBoxItem>())
{
if (item.CheckState == CheckState.Checked)
{
checkedItems++;
}
}
So, how to get the checked values from CheckedComboBoxEdit?
Upvotes: 0
Views: 1621
Reputation: 149
I found a simple answer. In order to get row value, you can use:
var s = vGridControl.GetCellValue(row1, vGridControl.FocusedRecord).ToString();
This shows a stored value for a row. Then you can convert it into the list:
var list = s.Split(',').ToList();
Upvotes: 1