[Gambas-user] Slow Gridview creation

Rolf-Werner Eilert eilert-sprachen at ...221...
Fri Mar 27 08:48:56 CET 2009


No, you don't fill it, it fills itself :-)

As soon as you change anything in the gridview (number of rows/columns 
for instance) or there is any event forcing it to rewrite its contents 
(the user switching screens or a .Refresh by your code), it jumps into 
the _Data event for every cell and reloads them.

So you just have to keep the contents prepared for it in the array in 
the background as Fabien has shown:

dim myarray[16000,16000]

Here is where you store your data for each cell.

As soon as you or your code gives the gridview a reason to start 
updating (in Fabien's example: Rows.Count and Columns.Count), it will 
jump into the _Data event and fetch its data for every cell from there:

public sub gridview1_data(row as integer, column as integer)

   gridview1.data.text = myarray[row, column]

end


Hope it helps...

Rolf


Jesus Guardon schrieb:
> Thanks for reply, but still not clear...
> 
> Your example only draws a grid with empty cells. I can't figure out how 
> to fill the grid with a database result object, even with a simple 
> array. Please, open my eyes!! :-((
> 
> Jesus
> 
> Fabien Bodard escribió:
>> in fact jesus , you don't feel the grid,
>> the grid just call the visible cells content via the event.
>>
>> dim myarray[16000,16000]
>>
>> public sub _New()
>>
>>   gridview1.Rows.Count = 16000
>>   gridView1.Columns.Count = 16000
>>
>> end
>>
>>
>> public sub gridview1_data(row as integer, column as integer)
>>
>>   gridview1.data.text = myarray[row, column]
>>
>> end
>>
>>
>> so you don't make any change in the data in the gridview but in the
>> array it self...
>>
>> it's a data/view model.  a variable that store the datas and a widget
>> that just walk on the content.
>>
>> 2009/3/26 Jesus Guardon <jguardon at ...2035...>:
>>> Hi all
>>>
>>> I'm trying to implement the Data event handler, but I cannot understand
>>> the way it must be done. I am locked out, sorry for my awkwardness.
>>> Can anyone provide a basic working example? I need to fill a gridview
>>> with 16000+ rows.
>>>
>>> Thanks in advance!
>>>
>>> Jesús
>>>
>>> Benoit Minisini escribió:
>>>
>>>> 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
>>>>
>>> ------------------------------------------------------------------------------
>>> _______________________________________________
>>> Gambas-user mailing list
>>> Gambas-user at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
> 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 





More information about the User mailing list