[Gambas-user] Huge data in gridview documentation wiki does not explain how

Tobias Boege taboege at ...626...
Tue May 16 23:10:08 CEST 2017


On Tue, 16 May 2017, PICCORO McKAY Lenz wrote:
> In gambas wiki documentation said:
> 
> You can fill the grid explicitly, or implement the Data
> <http://gambaswiki.org/wiki/comp/gb.qt4/gridview/.data> event to display
> the grid contents on demand.
> 
> You should use the last method if you have a lot of rows to display. The
> control can handle millions of lines gracefully.
> 
> but i try to set gridview.data event and set GridView1*.*Data*.*Text but
> when comes the object said it null (Data) ...
> 
> its there any example to load? i have a CSV and also a table db.. please
> its the documentation wrong?
> 

It's not. This method is so fast and easy on memory because you load the
GridView contents *on demand*. Read the text carefully: it tells you that
the GridView will raise the Data *event* (not the Data property; it even
links to the Data event documentation [1] which is IMHO comprehensive
enough) when it needs the contents of certain cells.

So, when the GridView control detects that it should display a certain cell,
identified by a Row and a Column number, it will raise the GridView_Data
event with just these Row and Column arguments. *During* such a Data event,
the GridView.Data property will contain a valid object and you have to
retrieve the cell data somehow (from your CSV file or database or ...) and
store it inside the GridView.Data property. You may only use the Data
property during the Data event.

If you still need an example, the IDE source code has some. You can also
look at the implementation of the ListBox control in gb.gui.base. It uses
the Data event of a GridView internally, too. (Who would've thought that
the ListBox is also just a GridView in disguise?)

Regards,
Tobi

[1] http://gambaswiki.org/wiki/comp/gb.qt4/gridview/.data

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list