I have collection bound to a checkedListBox in a winform and need the values of each checked item. The catch is that at runtime I do not know the property.
The list box populates as expected using the following code:
private void populateList(string feildName)
{
VwSelectionDataCollection coll = new VwSelectionDataCollection();
List<string> myList = new List<string>();
myList.Add(feildName);
coll.Query.Select(myList.ToArray());
coll.Query.GroupBy(myList.ToArray());
coll.Query.Load();
lstSelectionValues.DataSource = coll;
lstSelectionValues.ValueMember = feildName;
lstSelectionValues.DisplayMember = feildName;
}
On selection of an Item in the checkbox I am attempting to populate a list of values selected.
private void lstSelectionValues_SelectedIndexChanged(object sender, EventArgs e)
{
string myValue = "";
foreach (VwSelectionData myRow in lstSelectionValues.CheckedItems)
{
if (i > 0)
myValue += ",";
myValue +=
// This code works if the fieldname is Category but I need to pass the property name at runtime.
//myValue += myRow.Category.ToString();
}
grdCriteria.CurrentRow.Cells[2].Value = myValue;
}
This code can provide the property name but I’m not sure how to wire it up to provide the value of the property.
myRow.Collection.es.Meta.Columns.FindByColumnName("Category ").PropertyName.ToString();
Jeff