Gambas data grid code
Gambas source code.Gambas datagrid, gambas sample programs. Edit gambas data grid-mysql. Gambas-stock control programs. Gambas datagrid sample, gambas get text and gambas get text-mysql
https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-8621923297685973&output=html&h=60&adk=3133629799&adf=2690946030&w=468&lmt=1639255723&ad_type=text_image&format=468x60_as&color_bg=222222&color_border=222222&color_link=0066CC&color_text=FFFFFF&color_url=FFFFFF&url=http%3A%2F%2Fgambas-data-grid-codes-database.blogspot.com%2F&host=pub-1556223355139109&h_ch=0001%2BS0012%2BL0005&wgl=1&dt=1673536747648&bpp=15&bdt=1141&idt=832&shv=r20230110&mjsv=m202212010101&ptt=5&saldr=sa&abxe=1&correlator=2282768396222&frm=20&pv=2&ga_vid=2121539881.1673536748&ga_sid=1673536748&ga_hid=95612584&ga_fc=0&u_tz=330&u_his=1&u_h=864&u_w=1536&u_ah=816&u_aw=1536&u_cd=24&u_sd=1.25&adx=350&ady=376&biw=1519&bih=746&scr_x=0&scr_y=0&eid=44759876%2C44759927%2C44759837%2C31071268%2C21065724&oid=2&pvsid=4204862651671144&uas=0&nvt=1&eae=0&fc=640&brdim=0%2C0%2C0%2C0%2C1536%2C0%2C1536%2C816%2C1536%2C746&vis=1&rsz=%7C%7Cpe%7C&abl=CS&pfx=0&fu=0&bc=23&ifi=1&uci=a!1&fsb=1&xpc=mugRWiP1Ye&p=http%3A//gambas-data-grid-codes-database.blogspot.com&dtd=857
Wednesday, October 3, 2012
Add data to a gambas data grid
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
' Gambas class file |
PRIVATE $hConn AS NEW Connection |
PRIVATE $res AS Result |
'------------------------------------------------- |
PUBLIC SUB Form_Open() |
DIM iCount AS Integer |
DIM hTable AS Table |
DIM rTest AS result |
DIM sql AS String |
'define the gridview layout |
GridView1.header = GridView.Horizontal |
GridView1.grid = TRUE |
GridView1.Rows.count = 0 |
GridView1.Columns.count = 2 |
GridView1.Columns[0].text = "ID" |
GridView1.Columns[1].text = "Value" |
GridView1.Columns[0].width = 55 |
GridView1.Columns[1].width = 55 |
WITH $hConn |
.Type = "sqlite" |
.host = User.home |
.name = "" |
END WITH |
'delete an existing test.sqlite |
IF Exist(User.home & "/test.sqlite") THEN |
KILL User.home & "/test.sqlite" |
ENDIF |
'create test.sqlite |
$hConn.Open |
$hConn.Databases.Add("test.sqlite") |
$hconn.Close |
'define the table sampleTable |
$hconn.name = "test.sqlite" |
$hConn.Open |
hTable = $hConn.Tables.Add("sampleTable") |
hTable.Fields.Add("s_seq", db.Integer) |
hTable.Fields.Add("s_rndm", db.Integer) |
hTable.PrimaryKey = ["s_seq"] |
hTable.Update |
'fill the table with generated data |
$hconn.Begin |
rTest = $hConn.Create("sampleTable") |
FOR iCount = 1 TO 10000 |
rTest!s_seq = iCount |
rTest!s_rndm = Int(Rnd(0, 100)) |
rTest.Update |
NEXT |
$hConn.Commit |
'read the database |
sql = "select s_seq as ID, s_rndm as Value from sampleTable" |
$res = $hconn.Exec(sql) |
CATCH |
$hConn.Rollback |
Message.Error(DConv(Error.Text)) |
END |
'------------------------------------------------- |
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 |
END |
'------------------------------------------------- |
PUBLIC SUB GridView1_Data(Row AS Integer, Column AS Integer) |
$res.moveTo(row) |
GridView1.Data.text = Str($res[GridView1.Columns[column].text]) |
END |
'------------------------------------------------- |
PUBLIC SUB Form_Close() |
$hconn.Close |
END |