Click here to Skip to main content
16,022,190 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have listbox, and i add items threw datasource

how can i get selected item from listbox
Posted

Quote:
how can i get selected item from listbox

You can get the selected item from the list box using the ListBox.SelectedItem Property[^]
And if more than 1 items are selected, use the ListBox.SelectedItems Property[^]

Hope this helps.
 
Share this answer
 
Try:
C#
Console.WriteLine(myListBox.SelectedItem);
Or handle the SelectedIndexChanged or SelectedValueChanged events and pick it up there.
 
Share this answer
 
Comments
Thomas Daniels 13-Apr-13 4:17am    
Why Console.WriteLine if it's a Windows application and not a console application?
OriginalGriff 13-Apr-13 4:28am    
Safe place to dump it to show it works - in debug mode it goes to the VS Output pane.

Gotta show it going somewhere - and I have no idea of the OP form.

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