[Gambas-user] set of questions
charlesg
charles at ...1784...
Wed Oct 21 09:54:03 CEST 2009
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
'----------------------------------------------------------
rgds
--
View this message in context: http://www.nabble.com/set-of-questions-tp25987669p25988021.html
Sent from the gambas-user mailing list archive at Nabble.com.
More information about the User
mailing list