[Gambas-user] Populate grid with generic query

Fabien Bodard gambas.fr at ...626...
Thu Feb 20 21:45:09 CET 2014


You must to store the query result as private on the form


then

' Gambas class file

Private hResult As Result

Public Sub _new()

  Connections["Connection1"].Open
  ResultChange

End

Public Sub ResultChange()

  Dim hField As ResultField
  hResult = db.Find("tt")

  For Each hField In hResult.Fields
    Inc GridView1.Columns.Count
    GridView1.Columns[GridView1.Columns.Max].Text = hField.Name
  Next

  GridView1.Rows.Count = hResult.Count
  GridView1.Refresh

End

Public Sub GridView1_Data(Row As Integer, Column As Integer)
  'for fun

  If Column = 0 Then Last.Data.Font.Bold = True 'The first column is bold
  If row Mod 2 = 1 Then Last.Data.Background = Color.LightGray  'one
line on two is gray
  '**

  hResult.MoveTo(Row)

  Last.Data.Text = hResult[GridView1.Columns[Column].Text]

End

Public Sub ComboBox1_Click()

  'do your stuf on query
  ResultChange
End

2014-02-20 21:11 GMT+01:00 Daniel Quintero <dquinter at ...626...>:
> Hi all
>
> I've a beginer question:
>
> I have a simple query:
>
> select [list of fields]
> from [table]
> where [conditions]
>
> How can I populate a grid?
>
> My problem is that [list of fields], [table] and [conditions] can change
> depending on the values of various ComboBoxes
>
> Thanks in advance
>
> :)
>
> *_________________________*
> *Lic. Daniel Quintero Rojas*
>
> *¡Saludos desde México!________*
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user



-- 
Fabien Bodard




More information about the User mailing list