|
-
Dec 10th, 2006, 05:20 PM
#1
Thread Starter
Addicted Member
[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:
With Me.MSFlexGrid1
.Col = 5
For i = 2 to 7
.Row = i
Set .CellPicture = LoadPicture(App.Path & "\icon.ico")
Next
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.
-
Dec 10th, 2006, 05:55 PM
#2
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:
With MSFlexGrid1
.Redraw = False
.FillStyle = flexFillRepeat
' select cells
.Col = 5
.Row = 2
.RowSel = 7
Set .CellPicture = LoadPicture("C:\test.jpg")
.Col = 0: .Row = 0
.FillStyle = flexFillSingle
.Redraw = True
End With
-
Dec 10th, 2006, 06:03 PM
#3
Thread Starter
Addicted Member
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?.
-
Dec 10th, 2006, 06:15 PM
#4
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.
-
Dec 10th, 2006, 07:14 PM
#5
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|