Results 1 to 5 of 5

Thread: [RESOLVED] Fast method for Flexgrid formatting?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    160

    Resolved [RESOLVED] Fast method for Flexgrid formatting?

    I'm using a flexgrid where I display different events, and I want to add icons to them.

    Since each event can fill several cells that are then merged, I must (AFAIK) iterate through all those cells and set their cellpicture, so the picture can be seen in the merged cell. For example:

    VB Code:
    1. With Me.MSFlexGrid1
    2.     .Col = 5
    3.     For i = 2 to 7
    4.         .Row = i
    5.         Set .CellPicture = LoadPicture(App.Path & "\icon.ico")
    6.     Next
    7. End With

    However doing this is rather slow when I must set the picture of a lot of cells. Is there a faster way of formatting the cells?

    I've also adapted my code so I can add different categories for each event and so give them a different background colour, I haven't tested it yet, but it requires using the same method as far as I know.

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Fast method for Flexgrid formatting?

    you can change the FillStyle and then make changes to blocks of cells at once, e.g.:
    VB Code:
    1. With MSFlexGrid1
    2.         .Redraw = False
    3.         .FillStyle = flexFillRepeat
    4.        
    5.         ' select cells
    6.         .Col = 5
    7.         .Row = 2
    8.         .RowSel = 7
    9.         Set .CellPicture = LoadPicture("C:\test.jpg")
    10.        
    11.         .Col = 0: .Row = 0
    12.         .FillStyle = flexFillSingle
    13.         .Redraw = True
    14.     End With

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    160

    Re: Fast method for Flexgrid formatting?

    Thanks for your quick reply, I'll give it a try later. Out of curiosity, why do you change redraw and fillstyle at the end of the block?.

  4. #4
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Fast method for Flexgrid formatting?

    you get a performance improvement if you turn Redraw off when you make your changes (it prevents the control having to repaint with each change) - then turn it back once you've finished.

    regarding FillStyle, the default is flexFillSingle, so I changed it back to that - the behaviour of the control from the user's end might be different under the different FillStyles too.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    160

    Re: Fast method for Flexgrid formatting?

    Well, just changed my code, implementing what you've posted and it's faster without any doubt. Thanks for your tips.

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