Quantcast

Array data to Gridview?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Array data to Gridview?

Riccardo
Hi,






> I have a multidimensional array with 32,000 records. It takes quite a while to load this into a Gridview, and even longer if I provide the user with some feedback during the process (an updating label, a progress bar and so on...).

 

> Is there a faster way to load the array data into the Gridview? Currently, I'm iterating over the array and updating the Gridview cell by cell. Should I hide the Gridview during this process?
>
> For i = 1 To arr_Response.Length - 1
>     For j = 0 To arr_Response[i].Length - 1
>       grd_Response[i - 1, j].Text = arr_Response[i][j]
>     Next
> Next
>
> cheers.
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Array data to Gridview?

Tobias Boege-2
On Mon, 06 Feb 2017, Riccardo wrote:

> Hi,
>
>
>
>
>
>
> > I have a multidimensional array with 32,000 records. It takes quite a while to load this into a Gridview, and even longer if I provide the user with some feedback during the process (an updating label, a progress bar and so on...).
>
>  
>
> > Is there a faster way to load the array data into the Gridview? Currently, I'm iterating over the array and updating the Gridview cell by cell. Should I hide the Gridview during this process?
> >
> > For i = 1 To arr_Response.Length - 1
> >     For j = 0 To arr_Response[i].Length - 1
> >       grd_Response[i - 1, j].Text = arr_Response[i][j]
> >     Next
> > Next
> >
> > cheers.
> >

Look into the Data event of GridView. According to the documentation [1]:

  You can fill the grid explicitly, or implement the 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.

Regards,
Tobi

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

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

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Array data to Gridview?

Rolf-Werner Eilert-2
In reply to this post by Riccardo
Hi Riccardo,

just use the DATA event for the Gridview.

In short: You just define the number of Columns and Rows for the
Gridview. As soon as you define the Rows, the Gridview will begin to
load the contents for the cells by jumping into the Data event over and
over again.

You only have to make sure that for every Row there are data somewhere
in the program or make sure that if there are no data yet, there is some
code in the Data event which controls that. All other code for
displaying the contents in the cells is in the Data event.

The Data event will also be jumped in when the user scrolls the table.
The Gridview will only load the part of the Gridview which is visible.
Or when the user clicks on the form or makes it come to the front. That
means, besides from providing the cell data you don't have to care about
anything, and it is extremely fast.

Regards
Rolf


Am 06.02.2017 22:24, schrieb Riccardo:

> Hi,
>
>
>
>
>
>
>> I have a multidimensional array with 32,000 records. It takes quite a while to load this into a Gridview, and even longer if I provide the user with some feedback during the process (an updating label, a progress bar and so on...).
>
>
>
>> Is there a faster way to load the array data into the Gridview? Currently, I'm iterating over the array and updating the Gridview cell by cell. Should I hide the Gridview during this process?
>>
>> For i = 1 To arr_Response.Length - 1
>>      For j = 0 To arr_Response[i].Length - 1
>>        grd_Response[i - 1, j].Text = arr_Response[i][j]
>>      Next
>> Next
>>
>> cheers.
>>
>>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Loading...