Saturday, February 18, 2012

Gambas datagrid

Gambas data grid code not connected to a database

Private Sub PopulateCharges()
         Dim intRow As Integer = 0
         Dim strType As String = ""

         If rsCharges.Available Then
                 rsCharges.MoveFirst
                 grdCharge.Rows.Count = rsCharges.Count
                 For Each rsCharges
                         grdCharge[intRow, 0].Text = rsCharges!unique_id
                         grdCharge[intRow, 1].Text = rsCharges!charge_source
                         grdCharge[intRow, 2].Text = rsCharges!charge_type
                         grdCharge[intRow, 3].Text = rsCharges!charge_start
                         grdCharge[intRow, 4].Text = rsCharges!charge_end
                         grdCharge[intRow, 5].Text =
rsCharges!charge_display
                         Inc intRow
                 Next
                 modMain.UpdateStatus(rsCharges.Count & " Charge records
returned")
                 LoadChargeCombos(rsCharges)
                 grdCharge.Row = intRow - 1
         Endif
         Catch
             Message.Error(Error.Class.Name & ": " & Error.Where & ": "
& Error.Text)
End

I assume you have got your recordset (rsCharges) from the Db. You ned to
check how many rows are need in the grid and set this. Then populate
each row and column as above.

1 comment: