donnacha Posted July 17, 2003 Posted July 17, 2003 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 Quote Hamlet
aewarnick Posted July 17, 2003 Posted July 17, 2003 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. Quote C#
donnacha Posted July 21, 2003 Author Posted July 21, 2003 Hi aewarnick, I have solved this problem by using the re-sizing event and to re-scale the image there. Thanks Quote Hamlet
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.