Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...