[Gambas-user] Populate grid with generic query

Daniel Quintero dquinter at ...626...
Thu Feb 20 23:36:33 CET 2014


Ok, thanks :)

*_________________________*
*Lic. Daniel Quintero Rojas*

*¡Saludos desde México!________*



On Thu, Feb 20, 2014 at 3:55 PM, Fabien Bodard <gambas.fr at ...626...> wrote:

> 2014-02-20 22:47 GMT+01:00 Daniel Quintero <dquinter at ...626...>:
> > Hi Fabien, thanks for answering   :D
> >
> > I understood almost all code, except these two parts:
> >
> > Public Sub ResultChange()
> >
> >   Dim hField As ResultField
> > *   hResult = db.Find("tt")*
> >
> > *"tt"* is my query?
>
> no it's my table
>
> but you can use db.exec("SELECT * FROM tt")
>
> insteed
>
>
> >
> > And this:
> >
> > 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
> >
> > *Last* is a cell?
>
> No last is the widget that emit the event ... so the gridview in this case
>
>
> >
> > Thanks, as always, you are a person willing to help :)
> > *_________________________*
> > *Lic. Daniel Quintero Rojas*
> >
> > *¡Saludos desde México!________*
> >
> >
> >
> > On Thu, Feb 20, 2014 at 2:45 PM, Fabien Bodard <gambas.fr at ...626...>
> wrote:
> >
> >> 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
> >>
> >>
> >>
> ------------------------------------------------------------------------------
> >> 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
> >>
> >
> ------------------------------------------------------------------------------
> > 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
>
>
> ------------------------------------------------------------------------------
> 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
>



More information about the User mailing list