Loading and viewing datasets

Johnnh

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

I have a single form that needs to load different datasets into a list box from a main menu. This works fine until i go back and select a dataset prevously selected as the list box duplicates the enteries again and again. I have tried to clear the listbox upon the menu click but to no avail.I would be very gratefull anyone could advise. I have include the code im using which works upon one selection but duplicates on return.

VB.NET:
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
 
 
OleDbDataAdapter1.Fill(DataSet14)
ListBox1.DataSource = DataSet14.ANATOMY
ListBox1.DisplayMember = "EXAMINATION"
ListBox1.ValueMember = "IMAGEPATHjpeg"
DataGrid1.DataSource = DataSet14.ANATOMY
 
 
 
End Sub
 
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
 
OleDbDataAdapter2.Fill(DataSet21)
ListBox1.DataSource = DataSet21.FRACTURES
ListBox1.DisplayMember = "EXAMINATION"
ListBox1.ValueMember = "IMAGEPATHjpeg"
DataGrid1.DataSource = DataSet21.FRACTURES
 
End Sub
Many thanks
 
Last edited by a moderator:
Firstly, why are you using so many datasets's. You need to be using datatables and maybe just have one dataset to hold all the datatables. Secondly it may be that you have to set the datasource ofthe listbox to nothing first, then clear the items, then re-load the listbox.
 
Back
Top