I'm throwing myself on the mercy of the court here. I cannot get this DataGridView that is nested in a TabControl Tabpage3 to refresh without refreshing it twice. It's like a zombie DataGridView. I'm opening up a new form and writing dates to the database. When I close the pop-up form I'm calling TabControl1.SelectedIndexChanged which in turn calls this SchTabLoad. Everything fires, but the grid will not refresh until I manually refresh it. I really hope I'm just doing something stupid, because this is driving me nuts.
VB.NET Code:
Dim dtSch As New DataTable 'DataGridView4 Dim bs4 As New BindingSource Public Sub SchTabLoad(sender As Object, e As EventArgs) bs4.ResetBindings(False) DataGridView4.DataSource = Nothing bs4.DataSource = Nothing dtSch.Clear() 'Schedule Tab Production DataGridview4 Dim sqCon As New SqlClient.SqlConnection(DB) Dim sqCmd As New SqlClient.SqlCommand Dim Adapter As New SqlDataAdapter Dim sql As String = "SELECT * FROM Table" sqCmd.Connection = sqCon 'create the DB connection sqCon.Open() 'open the connection Adapter.SelectCommand = New SqlCommand(sql, sqCon) Adapter.Fill(dtSch) sqCon.Close() bs4.DataSource = dtSch Me.DataGridView4.DataSource = bs4 Me.DataGridView4.Refresh() End Sub




Reply With Quote
