[Gambas-user] GridView not refreshing

Doriano Blengino doriano.blengino at ...1909...
Thu Feb 5 08:14:29 CET 2009


M. Cs. ha scritto:
> Dear Benoit,
> having solved my previous problem with the GridView, now I'm facing a new
> one:
> I'm using a GridView table with 5 columns and tens of thousand rows. I'm
> working on a sorting problem. I want the GridView to sort its content for
> example by name.
> All the names are stored in an array, and paralelly the other 4 data in
> other arrays. I've created a sixth array with elements *name*index. *After
> this creation I'm sorting this Array with the .Sort() method. Everyting
> works fine, but having created the array of proper indices, when I invoke
> the GridView.Data(x,y) method simply nothing happens. Why?
>
> Part of the code:
> ....
> CASE 0
>
> FOR i = 0 TO gV.Rows.Count - 1     'Take the elements of first column and
> add a * and an index
> indexer.Add(gV[i, 0].Text & "*" & i)
> NEXT
>
> indexer.Sort(1) 'Sort the array ascending
>
> FOR i = 0 TO gV.Rows.Count - 1 *'Detach the index numbers from the sorted
> array and use index for the fill by splitting it*
> dubl = Split(indexer[i], "*")
> m = Val(dubl[1]) 'The index  of the element from the arrays which should
> stay in the i-th row
> gv_Data(m, 0)
> gv_Data(m, 1)
> gv_Data(m, 2)
> gv_Data(m, 3)
> gv_Data(m, 4)
> NEXT
>
> indexer.Clear()
> .....
>
> And the responding gV_Data:
>
> PUBLIC SUB gv_Data(x AS Integer, y AS Integer)
> SELECT CASE y
> CASE 0
>  gV.Data.Text = nev[x]
> CASE 1
>  gV.Data.Text = kotet[x]
> CASE 2
>  gV.Data.Text = ut[x]
> CASE 3
>  gV.Data.Text = nagy[x]
> CASE 4
>  gV.Data.Text = mikor[x]
>  END SELECT
> END
>
> All of these arrays are global arrays, available from all parts. I don't see
> the logical error, yet still nothing is happening. Why?
> Thanks!
>   
Instead of calling gv_Data(m, ...), try to do "gV.cells[m,...].text = 
..." (with the correct data, of course!).
The Data() event handler is called when the gridview wants to get its 
data; in that situation the property "Data" has a meaning. Outside that 
context, I think the Data property has no meaning. Moreover, Benoit 
would say that calling an event handler only serves to do dirty things...

There are two distinct ways to cope with data in gridview. One is to 
take control and assign values directly to cells[]; the gridview then is 
a window that reveals a part of the full grid, but the full grid 
contains already all the data; once filled, there is no need to do 
anything else. This method can take a long time to fill the grid, 
though. So another way is to load in the gridview only the data it can 
display at any moment: if the gridview has 10 visible rows, then you 
load just ten values; if the user scrolls down 20 rows, then you supply 
new 10 values, and so on. This is done by using the Data event.

Regards,

-- 
Doriano Blengino

"Listen twice before you speak.
This is why we have two ears, but only one mouth."





More information about the User mailing list