[Gambas-user] Slow Gridview creation
Benoit Minisini
gambas at ...1...
Wed Jan 28 21:55:37 CET 2009
On mercredi 28 janvier 2009, M. Cs. wrote:
> Dear Benoit,
> I would like to know whether it is possible to make GridView creation and
> filling process faster. I'm using databases for storage, then I'm doing the
> querries, which are giving tens of thousand results, or tens of thousand
> rows with five columns each. First, I put the results into five separated
> arrays, and afterwards I'm using them with a FOR...NEXT cycle. This is the
> code I'm using:
>
> visszhang = DBconX.Exec(quert)
> FOR EACH visszhang
> nev.Add(visszhang!"FName")
> ut.Add(visszhang!"FPath")
> nagy.Add(Round(visszhang!"FSize" / 1048576, -2))
> mikor.Add(visszhang!"FChanged")
> kotet.Add(point)
> NEXT
> dis = nev.Count
> gV.Rows.Count = dis
> FOR i = 0 TO dis - 1
> gV[i, 0].Text = nev[i]
> gV[i, 1].Text = kotet[i]
> gV[i, 2].Text = ut[i]
> gV[i, 3].Text = nagy[i]
> gV[i, 4].Text = mikor[i]
> NEXT
>
> But like this it takes eternity to create a table of 17.000 rows. There is
> a remark in Gambas documentation:
> * You should use the last
> method<file:///usr/share/gambas2/help/help/def/method.html>if you have
> thousands of rows to display.
> *What does it exactly mean? Can you recommend me a faster algorithm?
> Thanks!
You must do exactly what is written in the documentation: instead of setting
the data explicitely, you must implement the Data event handler. In this
event handler, you will receive the Row and Column of the cell to fill, and
in return you set the properties of the GridView.Data property to define the
cell contents.
PUBLIC SUB MyGridView_Data(Row AS Integer, Column AS Integer)
MyGridView.Data.Text = Row & " : " & Column
END
--
Benoit Minisini
More information about the User
mailing list