Shaitan00 Posted August 30, 2005 Posted August 30, 2005 Okay - as many people suggested I created an imagelist and added my 3 pictures to it (as shown in the code below). Problem I am having now, no clue how to get these now added images as background images to my buttons. (...if only ImageButtons existed...) Specifically - I have 3 buttons (btnStart, btnPause, btnStop) and I want to display the corresponding START, PAUSE, STOP images as their background. But I have no clue how to a) use the imagelist images I just added and b) set a background image to a button via code. private System.Windows.Forms.Button btnStart; private System.Windows.Forms.Button btnPause; private System.Windows.Forms.Button btnStop; private System.Windows.Forms.ImageList imglst; ... // Add Images to ImageList and display on buttons imglst.Images.Add(Image.FromFile("C:\\img\\Play.png")); imglst.Images.Add(Image.FromFile("C:\\img\\Pause.png")); imglst.Images.Add(Image.FromFile("C:\\img\\Stop.png")); btnStart.? btnPause.? btnStop.? [/Code] As you can see, I loaded my images... now what? How do I use them? How to I set them as the background image for the buttons? Thanks - I know I am asking for a lot but can't see to figure this part out, any help/hints would be appreciated. Quote
Shaitan00 Posted August 30, 2005 Author Posted August 30, 2005 Okay - I found a bit of code that worked great but I have one last question... (FYI: bit of code: myButton.BackgroundImage = myImageList.Images(0)) The size of the .PNG is a lot smaller then that of the actual button, currently there are like 6 copies of the START/PAUSE/STOP images in each button. I need to FIT/FILL/STRETCH the .PNG to fix the size of the button so there is only ONE start/pause/stop image per button (as it should be logically). Any clues? Quote
Machaira Posted August 30, 2005 Posted August 30, 2005 Set the ImageList and ImageIndex properties for the button instead of the BackGroundImage. Quote Here's what I'm up to.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.