Dataviewgrid with dynamic binding  
Author Message
Steve_Coder





PostPosted: Visual Basic Express Edition, Dataviewgrid with dynamic binding Top

I have a dataviewgrid and want to populate it with data based on the name of a table selected from a list box. Code I have:

Dim i As Integer

For i = 0 To StudentsDataSet.Tables.Count - 1

ListBox1.Items.Add(StudentsDataSet.Tables(i).ToString)

Next

'the above code gathers table names, just fine

Dim curItem As String = ListBox1.SelectedItem

With DataGridView1

.AutoGenerateColumns = True

.DataSource = StudentsDataSetBindingSource

.DataMember = curItem

End With

---this code puts in column headers but does not populate the grid....any suggestions for doing that



Visual Studio Express Editions38  
 
 
DMan1





PostPosted: Visual Basic Express Edition, Dataviewgrid with dynamic binding Top

you also have to change the datamember property of your databinding source and then it wouldn't be a bad idea to do a refresh of the view

 
 
goh6613





PostPosted: Visual Basic Express Edition, Dataviewgrid with dynamic binding Top

to Steve_Coder

Make sure ur datapropertyname is set correctly....


 
 
Steve_Coder





PostPosted: Visual Basic Express Edition, Dataviewgrid with dynamic binding Top

Yes thanks...my 1 grid will now display any of my tables' data...now I just have to get my 1 Navigator bar to have the grid rows move as I click on the various navigation arrows. And then to be able to save changes.