display listboxvalue member

Johnnh

Member
Joined
May 5, 2006
Messages
6
Programming Experience
Beginner
Hello

I need to show a listbox value member in a textbox but keep getting a " Cast from type 'DataRowView' to type 'String' is not valid" Ive also changed the selected value to a string in but recieve the same error, i am using 2 datasets that load into the same form so cannot assign the value from the listbox property panel as the database tables change.

Im very new to this and appreciate i am not using the best naming conventions on my code but would be v greatfull for any advice


Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click

ListBox1.DataSource = DataSet14.ANATOMY
ListBox1.DisplayMember = "EXAMINATION"
DataGrid1.DataSource = DataSet14.ANATOMY
ListBox1.ValueMember = "IMAGEPATHjpeg"


End Sub

Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click

ListBox1.DataSource = DataSet21.FRACTURES
ListBox1.DisplayMember = "EXAMINATION"
DataGrid1.DataSource = DataSet21.FRACTURES
ListBox1.ValueMember = "IMAGEPATHjpeg"


End Sub


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
OleDbDataAdapter1.Fill(DataSet14)
OleDbDataAdapter2.Fill(DataSet21)
End Sub



Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

l

TextBox2.Text = ListBox1.SelectedValue

End Sub
End Class
Thanks for looking
 
Listbox Value Member

hi
Apologies for duplicate

Ive already tried this in the code and it comes up with the same error
 
Back
Top