GirdView, limited lines
Posted
#1
(In Topic #2026)
Trainee

i open this new post because i have a problem
with a limited view in my Gridview.
I have a table of 226 lignes i can only see 113 lines…
I have another one of 742 lines and i can only see 371 lines.
It seems i can only see HALF of the table.
It seems to me that i already (many years ago, i just came back to Gambas)
encounter that problem.
What do you think ?
Posted
Trainee

- that i use PostgreSQL as Database…
- that i also use PostgreSQL with Lazarus for the same tables and it works perfectly fine.
Posted
Administrator



Some example code maybe to show how you populate the GridView?Zyfriala said
What do you think ?
From “GirdView, limited lines”, January 23rd 2026, 8:24 AM
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Trainee

'================================================================================
'============================ AFFICHE LA TABLE 'JOURNAL' ==========================
'================================================================================
Public Sub su_TableJournalAffiche()
'=== Pour la boucle
Dim l As Integer
'=== RAZ GRIDVIEW
Grid_Dev.Clear()
su_LignesCount("journal") '→ gives nLignes_h
'Message.Info("Table JOURNAL : " & nLignes_h)
su_GridShape("journal", 12, 10, nLignes_h)
su_LabelsEtColonnes("journal")
QueryPG_h = "Select lignes, jour_s, annee, mois, jour, cat, cat_sub, lien, titre, note1, note2 From sch_dev.t_dev_journal ORDER BY lignes "
'=== RECORDSET / EXECUTION DU RESULT
ResultConsult_h = $ConVisu.Exec(QueryPG_h)
'=== On avance au premier enregistrement
ResultConsult_h.MoveFirst
'=== Boucle
For l = 0 To nLignes_h - 1
'=== VARIABLES
'lignes,jour_s,annee,mois,jour,cat,cat_sub,lien,titre,note1,note2
$dev1 = ResultConsult_h!lignes
$dev2 = ResultConsult_h!jour_s
$dev3 = ResultConsult_h!annee
$dev4 = ResultConsult_h!mois
$dev5 = ResultConsult_h!jour
$dev6 = ResultConsult_h!cat
$dev7 = ResultConsult_h!cat_sub
$dev8 = ResultConsult_h!lien
$dev9 = ResultConsult_h!titre
$dev10 = ResultConsult_h!note1
$dev11 = ResultConsult_h!note2
'=== APPELLE LA FONCTION GridView1_Data
fo_GridView1_Ecrit(l, 0, $dev1)
fo_GridView1_Ecrit(l, 1, $dev2)
fo_GridView1_Ecrit(l, 2, $dev3)
fo_GridView1_Ecrit(l, 3, $dev4)
fo_GridView1_Ecrit(l, 4, $dev5)
fo_GridView1_Ecrit(l, 5, $dev6)
fo_GridView1_Ecrit(l, 6, $dev7)
fo_GridView1_Ecrit(l, 7, $dev8)
fo_GridView1_Ecrit(l, 8, $dev9)
fo_GridView1_Ecrit(l, 9, $dev10)
fo_GridView1_Ecrit(l, 10, $dev11)
l = l + 1
ResultConsult_h.MoveNext
Next
End
'==================================================================================
'===================== MAJ DES DONNEES DE LA GRIDVIEW =============================
'==================================================================================
Public Sub fo_GridView1_Ecrit(Row As Integer, Column As Integer, $data As Variant)
Grid_Dev[Row, Column].Text = $data
End
Posted
Enthusiast


Posted
Expert


'=== RECORDSET / EXECUTION DU RESULT
ResultConsult_h = $ConVisu.Exec(QueryPG_h)
Code
Message(str(ResultConsult_h.Count))
and compare this to your nLignes_h variable. They should be the same number.
I can't see how you are getting this count so assume that it is a query doing something like (?)
Code
SELECT COUNT(journal) AS JournalCount FROM sch_dev.t_dev_journal
I've never used Postgres but assume that the Gambas code below 'should' work ok doing this:
Code
ResultConsult_h = $ConVisu.Exec(QueryPG_h)
If Not IsNull(ResultConsult_h) and ResultConsult_h.Available then
For Each ResultConsult_h
(Code to load grid View rows)
Next
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Administrator



Like GianLuigi wrote, you should checkout the GridView_Data event.Zyfriala said
here we go…
From “Post #13,885”, January 23rd 2026, 11:22 AM
I'll try to come up with some example code to demonstrate how it works.
Going to bed now, it's past 3 AM here
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Administrator



Code (gambas)
- 'Gambas class file
- ' gvwResult = GridView
- 'A fictional demo where each record holds;
- ' Id (a database auto increment unique id)
- ' Name (a databas textbased field holding names)
- ' DateBirth (a database date field holding birth date)
- '$hConn is a fictional connection
- sQuery ="SELECT Id, Name, DateBirth FROM Persons ORDER BY Id"
- ReadData
- $rResult.MoveTo(Row)
- Select Column
- Case 2
- iHelp = $rResult[$sFieldName[Column]]
- '--This sets the number of records--
- gvwResult.Rows.Count = $rResult.Count
- '--This sets the number of fields (columns)--
- gvwResult.Columns.Count = $rResult.Fields.Count
- '--To store the column name--
- gvwResult.Columns[iX].Alignment = 3
- '--Get the fieldnames--
- iX = 0
- With hField
- gvwResult.Columns[iX].Text = .Name
- $sFieldName [iX]= .Name
- Inc iX
- '--set width of the columns--
- gvwResult.Rows.Height = 32
- gvwResult.Columns[0].Width = 60 'Id
- gvwResult.Columns[1].Width = 120 'Name
- gvwResult.Columns[2].Width = 95 'BirthDate
Seems, I had to quickly create a simple fictional example.
Hope you understand how GridView works and how to populate it correctly.
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Trainee

something was wrong in the loop and i didn't get all the results,
then i modify it
- i suppressed 'ResultConsult_h.MoveFirst
and just modify my loop like that
For l = 0 To nLignes_h - 1
ResultConsult_h.MoveTo(l)
fo_GridView1_Write(l, 0, ResultConsult_h[0]) '—Writing the datas
…
…
Next
works very fine
thank you both for your help and your ideas,
thanks gbWilly for your code
Posted
Enthusiast


Since I believe that using the gb.db2 DB class greatly facilitates database use under Gambas, I think I should insist.
I proposed my Farm example, but many believe that since the demonstration uses SQLite, it's not suitable for serious databases like PostgreSQL.
I also posted here: Problems with Buscar with Gambas in SQLite3 - Gambas ONE
an example I used to report a bug that works with all three of the most popular databases under GNU/Linux.
I'm adding here a reduction of the Farm example for Postgres.
I hope I've closed the loop.
It should also work on MySQL/MariaDB.
SpeedTestPostgres-0.0.1.tar.gz
1 guest and 0 members have just viewed this.

