We help IT Professionals succeed at work.

Flexgrid and icon size

lyners
lyners asked
on
I am using the MSflexgrid control in an application. I am assigning an icon to one of the row columns. The icon is appearing bigger then the cell. How do I get the icon to appear small enough to fit inside the flexgrid cell?
Comment
Watch Question

Head of Software Services
CERTIFIED EXPERT
Commented:
You have a few choices, you can either increase the size of the cell to the size of the icon or use an intermediate picture box to draw the icon onto and then into the cell:

    With MSFlexGrid1
        .Col = 1
        .Row = 4
        Picture1.Width = .RowHeight(.Row)
        Picture1.Height = .RowHeight(.Row)
        Picture1.AutoRedraw = True
        Picture1.PaintPicture LoadPicture("MyIcon.ico"), 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight
        Set .CellPicture = Picture1.Image
    End With

This paints the icon onto the picture box with the correct dimensions for the cell then loads this image into the cellpicture property.

Author

Commented:
This code seems like it will work. My problem now is that I am in MS Access with this, and I cannot seem to get a "picturebox" on a form. If you know how to, please let me know. As soon as I can get the picturebox on the form, I will test your code.

THANKS!

Should close this and give Tim the points

Explore More ContentExplore courses, solutions, and other research materials related to this topic.