Results 1 to 6 of 6

Thread: [RESOLVED] Assigning new DataSource to DataGridView

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2014
    Posts
    23

    Resolved [RESOLVED] Assigning new DataSource to DataGridView

    After correctly displaying data from one DataSource in my DataGridView I am assigning a different DataSource and calling the Refresh method but the new data is not rendering. I have confirmed new DataSource's dataset contains values. How can this be done?

    Initial load of DGV:

    Private Sub frmCodesetViewer_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    Me.CodeDescriptionTableAdapter1().Fill(Me.DsCodesets.CodeDescription)

    Me.CodeValuesTableAdapter().Fill(Me.DsCodesetValues.DataTable1, "A1")
    DataGridView1.DataSource = DsCodesetValues.DataTable1

    Dim r As DataRow = Me.DsCodesets.CodeDescription.Rows(0)
    txtCSDesc.Text = r.Item("Description")
    ComboBox2.Text = "(no filter)"
    End Sub

    Changing data source:

    Private Sub ComboBox2_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
    'Dim filter As String = "%" & ComboBox2.SelectedValue & "%"
    Dim filter As String = "%" & "Least" & "%"
    Me.FilteredValuesTableAdapter1.Fill(Me.DsFilteredValues1.DataTable1, SelectedCodeset, filter)
    DataGridView1.DataSource = DsFilteredValues1
    DataGridView1.Refresh()

    Dim r As DataRow = Me.DsCodesets.CodeDescription.Rows(ComboBox1.SelectedIndex)
    txtCSDesc.Text = r.Item("Description")
    End Sub

    Bob
    Last edited by bobmc; Mar 13th, 2014 at 07:23 AM. Reason: adding code snippets

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width