[Gambas-user] set of questions

Doriano Blengino doriano.blengino at ...1909...
Wed Oct 21 14:15:10 CEST 2009


Faysal Banna ha scritto:
> no no sir
> i was asking about the Grid View u were explaining to Dima ...
> besides i care to know a bit more about in place editing of cells inside the
> Grid View
> just click on the cell change the value..
>   
Uhm...

I never used a Gridview in that way, I simply worked out with my words 
something that already is in the docs (in a very unixish fashion). I 
tried to explain better what the idea behind Data event is.

But after that I have seen, in this thread, a complete example: I cut 
and paste:

> Hopefully this answers question 2. It is a distillation of the database
> example that comes with Gambas:
>
> You just need a gridview, a button called btnRun and a preferably large
> database with lots of columns so that you can scroll around with ease
>
> '========================================================
> ' Gambas class file
> PUBLIC $hConnLocl AS NEW Connection
> PUBLIC $resData AS Result
> '--------------------------------------------------------
> PUBLIC SUB Form_Open()
>   DIM sql AS String
>  
>   'open the database
>   WITH $hConnLocl
>     .type = "mysql"
>     .host = "localhost"
>     .Name = "stock"
>     .login = "charles"
>     .password="dog"
>   END WITH
>   $hConnLocl.Open()
>  
>   'create a result
>   sql = "SELECT * FROM grnLine"
>   $resData = $hConnLocl.Exec(sql)
>   END
> '---------------------------------------------------------
> PUBLIC SUB btnRun_Click()
>   DIM hForm AS FRequest
>   DIM hField AS ResultField
>   DIM iInd AS Integer
>
>   GridView1.Rows.count = 0
>   'set the required number of columns
>   GridView1.Columns.count = $resData.Fields.Count
>  
>   'define the column headers and width
>   FOR EACH hField IN $resData.Fields
>     WITH hField
>       GridView1.Columns[iInd].text = .Name
>       GridView1.Columns[iInd].width = 60
>     END WITH
>     INC iInd
>   NEXT
>  
>   'create the empty rows. Each empty and visible cell created calls
> GridView1_data
>   GridView1.Rows.Count = $resData.Count
> END
> '---------------------------------------------------------
> PUBLIC SUB GridView1_Data(Row AS Integer, Column AS Integer)
>   'move to the required result row
>   $resData.MoveTo(row)
>   'set the data for the cell in the GridView from the column in the selected
> row of the result
>   GridView1.Data.text = Str($resData[GridView1.Columns[column].text])
>   'lets you see how _data is being called as you scroll around the GridView
>   PRINT row & ":" & column & ":" &
> Str($resData[GridView1.Columns[column].text])
> END
> '----------------------------------------------------------
>   
Hope this is what you need.

Thanks for your nice appellation, "sir" :-), and regards.
Doriano Blengino







More information about the User mailing list