Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi By command “Listbox.SelectedIndex” we can access to index of an items of listbox which be selected by keyboard. But when I select an items of listbox by mouse click,
command “Listbox.SelectedIndex” return “-1”

How can I do this?
Thanks very much
Posted
Comments
Shafeequl 8-Jun-13 2:42am    
Ques is not clear...pls improve your question

SelectedIndex gives you the selected index, irrespective of user input.
Check you are accessing the selecteditem of the correct list box.
 
Share this answer
 
v2
This can't be. SelectedIndex will have the selected element indifferent how you select it: by mouse, keyboard, or tapping, or whatever. Don't you have multiselect enabled? Check SelectionMode, SelectedIndices and SelectedItem, SelectedItems properties respectively.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900