Results 1 to 4 of 4

Thread: Is there a faster way to resize grid?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Posts
    118

    Is there a faster way to resize grid?

    I need to resize a msflex grid. I am using DAO to fill the grid.
    This code works but is slow when I have a lot of results.

    Private Sub resizegrid()
    Dim r As Long, c As Long
    r = 1

    Do Until r >= MSFlexGrid1.Rows 'loop thru rows
    With MSFlexGrid1
    .Row = r
    For c = 0 To (.Cols - 1) 'move thru each cell in row
    .Col = c

    .RowHeight(r) = 600
    Next c
    End With
    r = r + 1


    Loop
    End Sub



    I could use a progress bar (if I knew how).

    Any Suggestions welcome.

  2. #2
    Frenzied Member John McKernan's Avatar
    Join Date
    Jan 2002
    Location
    SE PA
    Posts
    1,295
    Try this:
    VB Code:
    1. Private Sub resizegrid()
    2.    Dim r As Long, c As Long
    3.    r = 1
    4.  
    5.    MSFlexGrid1.Redraw = False   'turn off redrawing
    6.    Do Until r >= MSFlexGrid1.Rows 'loop thru rows
    7.       With MSFlexGrid1
    8.          .Row = r
    9.          For c = 0 To (.Cols - 1) 'move thru each cell in row
    10.             .Col = c
    11.  
    12.             .RowHeight(r) = 600
    13.          Next c
    14.       End With
    15.       r = r + 1
    16.    Loop
    17.    MSFlexGrid1.Redraw = True  'redraw grid
    18. End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Posts
    118

    Works great

    Thanks for the help!

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Is there more code in your For Loop that you are not showing? It doesn't make sense to call RowHeight for every column. In fact there is no need to use a loop at all. If you specify -1 as the row index to RowHeight all rows will be adjusted.

    The following method is instantaneous on a grid with 15000 rows and 10 cols - even on my PII 300mhz 128mb RAM.

    VB Code:
    1. With MSFlexGrid1
    2.     .Redraw = False
    3.     [B].RowHeight(-1) = 600[/B]    
    4.     .RowHeight(0) = 300 '
    5.     .Redraw = True
    6. End With

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width