Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi folks,

I have a bit map that is created externally that I want to use as a background image for a button but I want the image to be resized to fill the button space no matter how big the button is. I am currently using the following for putting the image in the button, but the image is either cropped or repeated.

 

Does anybody have an idea how to do this correctly.

 

Thanks for any help

 

 

Dim strm As System.IO.Stream

strm = (Me.GetType.Assembly.GetManifestResourceStream("Project.ButtonStyle1.bmp"))

Me.BackgroundImage = New Bitmap(strm) 'CType(strm, System.Drawing.Bitmap)

me.Name = "ButtonStyle1"

Me.ImageAlign = ContentAlignment.MiddleCenter

Me.FlatStyle = FlatStyle.Standard

Hamlet
Posted
Don't use that horrible backgroundimage property!! You will have to make your own button deriving from Button and override the OnPaint event painting your own image. I have done it not only with a button but with a form.
C#

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...