Data grid Codes
This event is raised when the GridView needs the data stored in a specified cell.
* Row is the cell row.
* Column is the cell column.
PUBLIC SUB GridView1_Data(Row AS Integer, Column AS Integer)
GridView1.Data.Text = "Gambas " & Row & "," & Column
END
Adding new records in a Gambas data grid
| PRIVATE $hConn AS NEW
Connection |
| '------------------------------------------------- |
| 'define the gridview layout |
| GridView1.header =
GridView.Horizontal |
| GridView1.Columns.count = 2 |
| GridView1.Columns[0].text =
"ID" |
| GridView1.Columns[1].text = "Value" |
| GridView1.Columns[0].width =
55 |
| GridView1.Columns[1].width = 55 |
| 'delete an existing test.sqlite |
| IF Exist(User.home &
"/test.sqlite") THEN |
| KILL User.home & "/test.sqlite" |
| $hConn.Databases.Add("test.sqlite") |
| 'define the table sampleTable |
| $hconn.name = "test.sqlite" |
| hTable = $hConn.Tables.Add("sampleTable") |
| hTable.Fields.Add("s_seq", db.Integer) |
| hTable.Fields.Add("s_rndm", db.Integer) |
| hTable.PrimaryKey = ["s_seq"] |
| 'fill the table with generated data |
| rTest = $hConn.Create("sampleTable") |
| rTest!s_rndm = Int(Rnd(0, 100)) |
| sql = "select s_seq as ID,
s_rndm as Value from sampleTable" |
| Message.Error(DConv(Error.Text)) |
| '------------------------------------------------- |
| PUBLIC SUB Form_Activate() |
| 'change the rowcount of the
gridview from 0 to the number of records. |
| 'This triggers the data
handling event |
| GridView1.Rows.Count = $res.Count |
| '------------------------------------------------- |
| PUBLIC SUB GridView1_Data(Row
AS Integer, Column AS Integer) |
| GridView1.Data.text = Str($res[GridView1.Columns[column].text]) |
| '------------------------------------------------- |
No comments:
Post a Comment