I’m populating a checklistbox with an object the processes a path into components. How do I get a specific property from the object associated with the selected index? I’m currently using the SelectedIndexChanged event I’ve tried SelectedItem, SelectedValue, SelectedIndex. I can get the property type, but not the value with checkedListBox1.SelectedValue.GetType().GetProperty(“fullPath”). Thanks.
Class1 c1;
List<object> files = new List<object>();
foreach(var value in filteredFiles1)
{
c1 = new Class1(value);
checkedListBox1.DisplayMember = "fileName";
files.Add(c1);
}
checkedListBox1.DataSource = files;
You should be able to cast the
CheckedListBoxSelectedItemto an instance of your class, and then access any properties within scope. Here is an example:I advise to do some additional checking to make sure the object is not null (i.e. in case the
SelectedIndexbecame -1).