[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gambas-user
Subject:    Re: [Gambas-user] Slow Gridview creation
From:       Benoit Minisini <gambas () users ! sourceforge ! net>
Date:       2009-01-28 20:55:37
Message-ID: 200901282155.37660.gambas () users ! sourceforge ! net
[Download RAW message or body]

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

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic