Information générale
Titre:
Getting selected item from ListBox control
Versions des environnements
Network:
Windows 2003 Server
I'm developing a Windows Forms application that includes a ListBox control.
I have created a handler for the Click event.
But, I am not able to get the value of the SelectedItem. Here is the offending line:
string SessDate = (string)(listBox1.SelectedItem);
I get an error message saying "Unable to cast object of type 'System.Data.DataRowView' to type 'System.String'.
When I run under the debugger, I can see this.ListBox and that shows {SelectedItem = "10/25/2002"} which is what I am trying to get.
Help!
Thanks,
Jim
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement