From gambas-user Wed Jan 28 20:55:37 2009 From: Benoit Minisini Date: Wed, 28 Jan 2009 20:55:37 +0000 To: gambas-user Subject: Re: [Gambas-user] Slow Gridview creation Message-Id: <200901282155.37660.gambas () users ! sourceforge ! net> X-MARC-Message: https://marc.info/?l=gambas-user&m=123317626412393 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 > methodif 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