listbox - valuemember access
-
Hi all, I would like to know of how to get the value member of every item in the listbox. It is clear that i can get the valumember of the selected item using the selectedvalue property. But my requirement is that i need to check the values of all the items immaterial of if it is selected or not. How can this be achieved? please help me out with this. Thanks in advance Regards, Madhusri Thanks and Regards MadhuSri
-
Hi all, I would like to know of how to get the value member of every item in the listbox. It is clear that i can get the valumember of the selected item using the selectedvalue property. But my requirement is that i need to check the values of all the items immaterial of if it is selected or not. How can this be achieved? please help me out with this. Thanks in advance Regards, Madhusri Thanks and Regards MadhuSri
Try this one:
for (int index = 0; index < listBox.Items.Count; index++)
{
PropertyInfo info = listBox.Items[index].GetType().GetProperty(listBox.ValueMember);
object valuemember = info.GetValue(listBox.Items[index], null);
}
-
Try this one:
for (int index = 0; index < listBox.Items.Count; index++)
{
PropertyInfo info = listBox.Items[index].GetType().GetProperty(listBox.ValueMember);
object valuemember = info.GetValue(listBox.Items[index], null);
}
Stefan Troschütz wrote:
for (int index = 0; index < listBox.Items.Count; index++) { PropertyInfo info = listBox.Items[index].GetType().GetProperty(listBox.ValueMember); object valuemember = info.GetValue(listBox.Items[index], null);}
Stefan, thanks for the sample code. it helped me to get the valuemamber. Thanks and Regards Madhu