Image backround on form

Knoodle
02-26-2004, 12:28 PM
I need help on using an image as the backround for a form and am having a hard time finding the appropriate help file(s). I linked to an image using the form BackgroundImage property, but the image shows up as multiple panels on the form. Do I have to use another program (like photoshop or paint or... ) and import the image in the BackgroundImage Property, or can it be done entirely in VB.net?
Thanks for any help, and any links to tutorials... I'm a .net and graphics newbie.

MikeJ
02-26-2004, 02:57 PM
You can accomplish this with GDI+. Try something like this:

Imports System.Drawing

Private Class Form1
Inherits System.Window.Forms.Form

'Window Design Generator Code
'Other code on your form

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
'This is our graphics object.
Dim g As Graphics = e.Graphics

'This is how we store our image
Dim iImage As Bitmap = New Bitmap("C:\Path\To\My.bmp")
Dim bBackground As TextureBrush = New TextureBrush(iImage)

'This paints our form's background
g.FillRectangle(bBackground, New Rectangle(0, 0, Me.Width, Me.Height))
End Sub
End Class

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum