I have a checkedListBox on a winform. I fill the check box with some code see below.
All works well.
Now I need to get the value of the checked items. I am having some issues.
When I do the foreach(var item in clbtest.CheckedItems)
I get this when doing a Immediate window... ? item
{ Text = "Depos", Value = "Q:\\Scanning Department\\_DT SEARCH INDEXES\\Depos" }
Text: "Depos"
Value: "Q:\\Scanning Department\\_DT SEARCH INDEXES\\Depos"
I don't know how to get at the Value field. I have tried several ways but nothing seems to work.
private void FillIndexes()
{
string stext = cblIndexToSearch.Text;
cblIndexToSearch.Items.Clear();
cblIndexToSearch.Text = "";
cblIndexToSearch.DisplayMember = "Text";
cblIndexToSearch.ValueMember = "Value";
foreach (var item in indexlist)
{
cblIndexToSearch.Items.Insert(0,
new { Text = item.indexName, Value = @item.indexPath });
}
}