ListBox ValueMember
-
Hi, Can we have a ListBox ValueMember Collection? If we have SelectionMode as MultiExtended, and we select more than one values in the listbox, then can we show its respective value member as we can show the SelectedIndices (Collection of selected index) If there is a way could you please post an example with it.. And if there is not then What are the alternatives (without using and temp array to kepp track of it..some memory mgmt is required here) Thanks a lot
-
Hi, Can we have a ListBox ValueMember Collection? If we have SelectionMode as MultiExtended, and we select more than one values in the listbox, then can we show its respective value member as we can show the SelectedIndices (Collection of selected index) If there is a way could you please post an example with it.. And if there is not then What are the alternatives (without using and temp array to kepp track of it..some memory mgmt is required here) Thanks a lot
-
try out following codes for(int i=0;i < listBox1.Items.Count;i++) { if(listBox1.GetSelected(i)) { MessageBox.Show("",listBox1.GetItemText(listBox1.Items[i])); } } rahul -- modified at 5:25 Thursday 11th May, 2006
This would work absolutely fine, but you did not get my problem I am displaying some value in the listbox and actually require some different value, say for e.g. i am showing names in the box whereas if the user selects a name i am retriving the corresponding employee ID for that name. Now this scenario is possible through ValueMember and DisplayMember property of ListBox. DisplayMember = name ValueMember = empId Now the code which you gave me works fine if i need to retrive the DisplayMembers from listbox.. My question though,here was i needed the ValueMembers to corresponding selection Thanks a lot -- modified at 6:14 Thursday 11th May, 2006