Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Icons and Command Buttons

Status
Not open for further replies.

SSJ

Programmer
Sep 26, 2002
54
PT
I'm trying to use an icon inside a command button. (Not one icon actually around 64 icons into 64 command buttons).
I can easily do that with the Picture Property, the thing is my icons are all 32x32 and they are too big for the command buttons I'd need to use them smaller is there any way of doing it?
If I insert them on a ImageList of 16x16 they will look exactly the way I want them, can I do the same on a Command Button?
 
Or is there any way of loading the image from an ImageList into a command Button? That might also solve my problem.

TIA
 
To load an image from a list image control onto a command button use the following line of code.

Command1.Picture = ImageList1.ListImages(1).Picture

Where 'ListImages(1)' is the first image stores in the list image control. Also make sure that yur button is set to graphical. Thanks and Good Luck!

zemp
 
If your command buttons are in a control array (I assume they are, if not CHANGE IT!!!), you can easily creae a loop to put the images on the buttons from an image list.

Code:
Private Sub Form_Load()
    For I = 1 to 64
        cmdButton(I).Picture = ImageList1.ListImages(I).Picture
    Next
End Sub
[Thanks in advance|Hope I helped you]
Exodus300
[pc3]
 
If you want your images easily available to all forms then you can also place them in a resource file and load them as follows,

Command1.picture = LoadResPicture(1, vbResIcon)

Where 1 is the index given to the image in the resource file. Check on the constant 'vbREsIcon', it may be different for non .ico files. Thanks and Good Luck!

zemp
 
ok tkz a lot that was just what I was looking for! And zemp the resource file tip is also good, I had never worked with that I'll give it a look.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top