with this code I populate a devexpress gridcontrol, everything is ok:
Private Sub tbccegek_SelectedPageChanged(ByVal sender As Object, ByVal e As DevExpress.XtraTab.TabPageChangedEventArgs) Handles tbccegek.SelectedPageChanged
If tbccegek.SelectedTabPageIndex = 3 Then
'gcCegek.DataSource = Nothing
ConnectToDb(fbconn, "public")
fbcommand.Connection = fbconn
fbcommand.CommandText = "select cegazon, rovidnev, irsz||' '||varos||' '||utca||' '||hazszam as cim, adoszam, konyvpnem, osszktg_forg from cegek order by cegazon"
fbadapter.SelectCommand = fbcommand
fbadapter.Fill(fbdataset)
fbdataset.Tables(0).TableName = "cegek"
gcCegek.DataMember = "cegek"
gcCegek.DataSource = fbdataset
For i = 0 To fbdataset.Tables(0).Rows.Count - 1
If fbdataset.Tables(0).Rows(i).Item(5) = "1" Then
fbdataset.Tables(0).Rows(i).Item(5) = "Összköltség"
ElseIf fbdataset.Tables(0).Rows(i).Item(5) = "0" Then
fbdataset.Tables(0).Rows(i).Item(5) = "Forgalmi ktg."
End If
Next
gcCegek.MainView.PopulateColumns()
columnview = gcCegek.MainView
columnview.Columns(0).Caption = "Cégazonosító"
columnview.Columns(1).Caption = "Cégnév (rövid)"
columnview.Columns(2).Caption = "Cím"
columnview.Columns(3).Caption = "Adószám"
columnview.Columns(4).Caption = "K.pnem"
columnview.Columns(5).Caption = "Ktg.elsz"
GridView1.BestFitColumns()
fbconn.Close()
End If
End Sub
But if I modify in the app a record, then save it via an update sql to the database and click again on the tab, on which the gridcontrol is, I see, that the value in the gridcontrol didn't change. But in the database, there is the modified value.
As you see, on the tabpage changing event I populate the grid from the very beginning, in my opinion there should be the modified value too.
Can you help me out?
The solution to this problem is to refetch data from the DB again to the DataSource to which the grid is connected to. In this case, the grid will know that data was changed and refreshes its contents.
Also, I suggest that you set the breakpoint in the event handler you posted and make certain that the actual modified data is fetched from the DB.
Also, it is more correct to use the following code:
if not e.Page Is Nothing andalso e.Page.SelectedTabPageIndex = 3 Then
...