By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,557 Members | 1,406 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,557 IT Pros & Developers. It's quick & easy.

how to put a scalable image into a form (or panel)

P: n/a
I'm a Java developer relatively new to to VB .NET (and I don't know
the old VB6 at all). I know how to draw lines, circles and other
simple shapes on a form in VB.NET (using the onPaint event).

Could someone out there please give me a simple example, or point me
to a SIMPLE example that:

1) puts a given JPEG (or GIF, or TIF) image into a form or panel (or
whatever other control is appropriate)

2) allows me to re-size the form or panel in the usual manner by
grabbing a corner with the mouse pointer and dragging it.
As I resize the form, the image is to re-scale itself, as appropriate,
to keep the form/panel filled completely.

Thanks for any help and advice,

Wolfgang
Santa Barbara, CA
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Wolfgang" <rn***@nospam.ilternet.edu> schrieb:
I'm a Java developer relatively new to to VB .NET (and I don't know
the old VB6 at all). I know how to draw lines, circles and other
simple shapes on a form in VB.NET (using the onPaint event).

Could someone out there please give me a simple example, or point me
to a SIMPLE example that:

1) puts a given JPEG (or GIF, or TIF) image into a form or panel (or
whatever other control is appropriate)

2) allows me to re-size the form or panel in the usual manner by
grabbing a corner with the mouse pointer and dragging it.
As I resize the form, the image is to re-scale itself, as appropriate,
to keep the form/panel filled completely.


For example:

\\\
Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms

Public Class UserControl1
Inherits Panel

Public Sub New()
Me.SetStyle(ControlStyles.ResizeRedraw, True)
Me.UpdateStyles()
End Sub

Protected Overrides Sub OnPaintBackground( _
ByVal e As PaintEventArgs _
)
If Not Me.BackgroundImage Is Nothing Then
e.Graphics.DrawImage( _
Me.BackgroundImage, 0, 0, Me.Width, Me.Height _
)
End If
End Sub
End Class
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.