473,756 Members | 7,817 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to eliminate Tiling of windows forms background images

I want to place a background image on a windows form. Is there a way to
prevent the image from Tiling without using an image box resized to the size
of the form?
I am using Visual Studio 2003 .NET. This is an easy thing to do in VB6.
Jul 21 '05 #1
8 3773
Hi,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need the background image size to
be the same as client rectangle by stretching instead of tiling. If there
is any misunderstandin g, please feel free to let me know.

As far as I know, this cannot be implemented so simply as in VB6. We can
try to override the OnPaint event to achieve this. When painting, we just
use Graphics.DrawIm age to draw the particular bitmap to the client area.
Here is an example:

private void Form1_Paint(obj ect sender,
System.Windows. Forms.PaintEven tArgs e)
{
Bitmap b = new Bitmap(@"D:\My Documents\My Pictures\untitl ed.bmp");
e.Graphics.Draw Image(b,
this.ClientRect angle.X,this.Cl ientRectangle.Y ,this.ClientRec tangle.Width,
this.ClientRect angle.Height);
}

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #2
Hi,
Thank you for your reply. Yes, you have a complete understanding of my
problem. I am a visual basic programmer and will have to study your C# code
closely to see if I can glean a vb method to accomplish importing my image
file using the OnPaint event. Thank you again for your response. Are you able
to provide an example of this procedure in visual basic code? Thanks again.

"Kevin Yu [MSFT]" wrote:
Hi,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need the background image size to
be the same as client rectangle by stretching instead of tiling. If there
is any misunderstandin g, please feel free to let me know.

As far as I know, this cannot be implemented so simply as in VB6. We can
try to override the OnPaint event to achieve this. When painting, we just
use Graphics.DrawIm age to draw the particular bitmap to the client area.
Here is an example:

private void Form1_Paint(obj ect sender,
System.Windows. Forms.PaintEven tArgs e)
{
Bitmap b = new Bitmap(@"D:\My Documents\My Pictures\untitl ed.bmp");
e.Graphics.Draw Image(b,
this.ClientRect angle.X,this.Cl ientRectangle.Y ,this.ClientRec tangle.Width,
this.ClientRect angle.Height);
}

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #3
Of course, here is the VB.NET code.

Private Sub Form1_Paint(ByV al sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs) Handles MyBase.Paint
Dim b As New System.Drawing. Bitmap("D:\My Documents\My
Pictures\untitl ed.bmp")
e.Graphics.Draw Image(b, Me.ClientRectan gle.X, Me.ClientRectan gle.Y,
Me.ClientRectan gle.Width, Me.ClientRectan gle.Height)
End Sub

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #4
Ron,
In addition to (instead of) handling the Paint event as Kevin showed, I
would consider overriding the OnPaintBackgrou nd method, as the
OnPaintBackgrou nd is the method that paints the background.

Something like:

Protected Overrides Sub OnPaintBackgrou nd(ByVal e As PaintEventArgs)
If Me.BackgroundIm age Is Nothing Then Exit Sub
e.Graphics.Draw Image(Me.Backgr oundImage, Me.ClientRectan gle)
End Sub

NOTE: You do not want (or need) to call MyBase.OnPaintB ackground as you are
painting the entire background.

http://msdn.microsoft.com/library/de...roundtopic.asp

The following articles discusses the OnPaintBackgrou nd method:
http://msdn.microsoft.com/library/de...rmscontrol.asp

Hope this helps
Jay

"Ron Holmes" <vb**********@n oemail.nospam> wrote in message
news:A2******** *************** ***********@mic rosoft.com...
Hi,
Thank you for your reply. Yes, you have a complete understanding of my
problem. I am a visual basic programmer and will have to study your C#
code
closely to see if I can glean a vb method to accomplish importing my image
file using the OnPaint event. Thank you again for your response. Are you
able
to provide an example of this procedure in visual basic code? Thanks
again.

"Kevin Yu [MSFT]" wrote:
Hi,

First of all, I would like to confirm my understanding of your issue.
From
your description, I understand that you need the background image size to
be the same as client rectangle by stretching instead of tiling. If there
is any misunderstandin g, please feel free to let me know.

As far as I know, this cannot be implemented so simply as in VB6. We can
try to override the OnPaint event to achieve this. When painting, we just
use Graphics.DrawIm age to draw the particular bitmap to the client area.
Here is an example:

private void Form1_Paint(obj ect sender,
System.Windows. Forms.PaintEven tArgs e)
{
Bitmap b = new Bitmap(@"D:\My Documents\My Pictures\untitl ed.bmp");
e.Graphics.Draw Image(b,
this.ClientRect angle.X,this.Cl ientRectangle.Y ,this.ClientRec tangle.Width,
this.ClientRect angle.Height);
}

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #5
Please excuse my stupidity but I upgraded my vb6 program to

VS .NET 2003 and in my VB6 application, I stored the Form1

Background_Pict ure in my applications emts.ini file. During

the Form1 load event I use the following procedure to get

the backgroung picture location and file name:

In my VB6 BAS Module I have defined pix globally:

Public pix as string

'Procedure to Get the Form1.Picture from emts.ini

pix = VBGetPrivatePro fileString("Bac kground_Picture ",

"Path", "c:\Program Files\Holmes

Industries\Mega tech32\emts.ini ")

Next, I used the following procedure to load the file as

the Form1 background:

Form1.DefInstan ce.BackgroundIm age = System.Drawing. Image.FromFile( pix)

This caused the objectionable Tileing that I was

describing.

I placed the code that you so kindly sent me, into my

form1 Paint event and replaced the "D:\My Documents\My

Pictures\untitl ed.bmp" with the global value pix as shown

here:

Dim b As New System.Drawing. Bitmap("D:\My Documents\My

Pictures\untitl ed.bmp") AS

Dim b As New System.Drawing. Bitmap(pix)

and now I can't figure out how to call the Form1_Paint

procedure as the call wants an event as sender ( the e

variable in your code ).

e.Graphics.Draw Image(b, Me.ClientRectan gle.X, Me.ClientRectan gle.Y,
Me.ClientRectan gle.Width, Me.ClientRectan gle.Height)

I would like the background to load automatically during the form load
procedure but without the Tiling?????

Thank you for all of your help.
After 10 years of using VB3, VB4, VB5 and recently VB6, I never knew how
little I know about programming until I tried using VS .NET 2003. You are
suggestion I consider overriding the OnPaintBackgrou nd method and I am
realizing that I don't know how to do this. I know I am asking too much but
this is very confusing. I wrote a very involved program to track equipment
maintenance problems. My VB6 application's executible is over 6 MB in size
and really works quite well and I never heard of any of this. What should I
do next after the form1_Load code shown below?

'Procedure to Get the Form1.Picture from emts.ini

pix = VBGetPrivatePro fileString("Bac kground_Picture ", "Path", "c:\Program
Files\Holmes Industries\Mega tech32\emts.ini ")

Next, I used the following procedure to load the file as the Form1 background:

Form1.DefInstan ce.BackgroundIm age = System.Drawing. Image.FromFile( pix)

This is when the background Tiling appeared.

I think the RAD (Rapid Application Development) name is wishful thinking. At
least until you learn the 10 thousand other things you never knew about,
while using the former languages. I admire you guys who have attained the MVP
rating, and I know you know what I mean when I say this new language is
confusing. Thank you for replying to my cry for HELP!!!
Do I Paste the code below in the Form1_Paint event?

Protected Overrides Sub OnPaintBackgrou nd(ByVal e As PaintEventArgs)
If Me.BackgroundIm age Is Nothing Then Exit Sub
e.Graphics.Draw Image(Me.Backgr oundImage, Me.ClientRectan gle)
End Sub
If I do paste this code... where does the picture file information go?
"Jay B. Harlow [MVP - Outlook]" wrote:
Ron,
In addition to (instead of) handling the Paint event as Kevin showed, I
would consider overriding the OnPaintBackgrou nd method, as the
OnPaintBackgrou nd is the method that paints the background.

Something like:

Protected Overrides Sub OnPaintBackgrou nd(ByVal e As PaintEventArgs)
If Me.BackgroundIm age Is Nothing Then Exit Sub
e.Graphics.Draw Image(Me.Backgr oundImage, Me.ClientRectan gle)
End Sub

NOTE: You do not want (or need) to call MyBase.OnPaintB ackground as you are
painting the entire background.

http://msdn.microsoft.com/library/de...roundtopic.asp

The following articles discusses the OnPaintBackgrou nd method:
http://msdn.microsoft.com/library/de...rmscontrol.asp

Hope this helps
Jay

"Ron Holmes" <vb**********@n oemail.nospam> wrote in message
news:A2******** *************** ***********@mic rosoft.com...
Hi,
Thank you for your reply. Yes, you have a complete understanding of my
problem. I am a visual basic programmer and will have to study your C#
code
closely to see if I can glean a vb method to accomplish importing my image
file using the OnPaint event. Thank you again for your response. Are you
able
to provide an example of this procedure in visual basic code? Thanks
again.

"Kevin Yu [MSFT]" wrote:
Hi,

First of all, I would like to confirm my understanding of your issue.
From
your description, I understand that you need the background image size to
be the same as client rectangle by stretching instead of tiling. If there
is any misunderstandin g, please feel free to let me know.

As far as I know, this cannot be implemented so simply as in VB6. We can
try to override the OnPaint event to achieve this. When painting, we just
use Graphics.DrawIm age to draw the particular bitmap to the client area.
Here is an example:

private void Form1_Paint(obj ect sender,
System.Windows. Forms.PaintEven tArgs e)
{
Bitmap b = new Bitmap(@"D:\My Documents\My Pictures\untitl ed.bmp");
e.Graphics.Draw Image(b,
this.ClientRect angle.X,this.Cl ientRectangle.Y ,this.ClientRec tangle.Width,
this.ClientRect angle.Height);
}

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Jul 21 '05 #6
Ron,
the Form1 background:

Form1.DefInstan ce.BackgroundIm age = System.Drawing. Image.FromFile( pix)
I would set BackgroundImage in the Load event with the following:
Me.BackgroundIm age = System.Drawing. Image.FromFile( pix)
Simply to ensure that all instances of the form have the property set.

and now I can't figure out how to call the Form1_Paint
procedure as the call wants an event as sender ( the e
variable in your code ). You DO NOT call it as its a form level event, the form itself will call it
when it needs to be called.

VB (.NET, 1, 2, 3, 4, 5, 6) 101. Paint is an event handler for the form
itself, you need to select the Paint event from combo boxes at the top of
the editor to add a handler for the Paint event. Which will add a routine
such as:

Private Sub MainForm_Paint( ByVal sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs) Handles MyBase.Paint
' Kevin's code
End Sub

Alternatively you can override the OnPaint method, as the OnPaint method
raises the Paint event (this should have been explained in the link I gave).

' you can (and should) use the following instead of the above
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint( e) ' important this needs to be called!
' Kevin's code
End Sub

OnPaintBackgrou nd is only an overriden method.
Protected Overrides Sub OnPaintBackgrou nd(ByVal e As PaintEventArgs)
If Me.BackgroundIm age Is Nothing Then Exit Sub
e.Graphics.Draw Image(Me.Backgr oundImage, Me.ClientRectan gle)
End Sub
The paint event (Paint or OnPaint) & OnPaintBackgrou nd are automatically
called by the form itself when the form needs to be painted (when you or
windows calls Form.Update either directly or indirectly). This should also
have been explained in the link I gave.

You should only use Paint event or OnPaintBackgrou nd routine, not both.

Again the link I gave should explain when to use on or the other.

Hope this helps
Jay

"Ron Holmes" <vb**********@n oemail.nospam> wrote in message
news:8A******** *************** ***********@mic rosoft.com... Please excuse my stupidity but I upgraded my vb6 program to

VS .NET 2003 and in my VB6 application, I stored the Form1

Background_Pict ure in my applications emts.ini file. During

the Form1 load event I use the following procedure to get

the backgroung picture location and file name:

In my VB6 BAS Module I have defined pix globally:

Public pix as string

'Procedure to Get the Form1.Picture from emts.ini

pix = VBGetPrivatePro fileString("Bac kground_Picture ",

"Path", "c:\Program Files\Holmes

Industries\Mega tech32\emts.ini ")

Next, I used the following procedure to load the file as

the Form1 background:

Form1.DefInstan ce.BackgroundIm age = System.Drawing. Image.FromFile( pix)

This caused the objectionable Tileing that I was

describing.

I placed the code that you so kindly sent me, into my

form1 Paint event and replaced the "D:\My Documents\My

Pictures\untitl ed.bmp" with the global value pix as shown

here:

Dim b As New System.Drawing. Bitmap("D:\My Documents\My

Pictures\untitl ed.bmp") AS

Dim b As New System.Drawing. Bitmap(pix)

and now I can't figure out how to call the Form1_Paint

procedure as the call wants an event as sender ( the e

variable in your code ).

e.Graphics.Draw Image(b, Me.ClientRectan gle.X, Me.ClientRectan gle.Y,
Me.ClientRectan gle.Width, Me.ClientRectan gle.Height)

I would like the background to load automatically during the form load
procedure but without the Tiling?????

Thank you for all of your help.
After 10 years of using VB3, VB4, VB5 and recently VB6, I never knew how
little I know about programming until I tried using VS .NET 2003. You are
suggestion I consider overriding the OnPaintBackgrou nd method and I am
realizing that I don't know how to do this. I know I am asking too much
but
this is very confusing. I wrote a very involved program to track equipment
maintenance problems. My VB6 application's executible is over 6 MB in size
and really works quite well and I never heard of any of this. What should
I
do next after the form1_Load code shown below?

'Procedure to Get the Form1.Picture from emts.ini

pix = VBGetPrivatePro fileString("Bac kground_Picture ", "Path", "c:\Program
Files\Holmes Industries\Mega tech32\emts.ini ")

Next, I used the following procedure to load the file as the Form1
background:

Form1.DefInstan ce.BackgroundIm age = System.Drawing. Image.FromFile( pix)

This is when the background Tiling appeared.

I think the RAD (Rapid Application Development) name is wishful thinking.
At
least until you learn the 10 thousand other things you never knew about,
while using the former languages. I admire you guys who have attained the
MVP
rating, and I know you know what I mean when I say this new language is
confusing. Thank you for replying to my cry for HELP!!!
Do I Paste the code below in the Form1_Paint event?

Protected Overrides Sub OnPaintBackgrou nd(ByVal e As PaintEventArgs)
If Me.BackgroundIm age Is Nothing Then Exit Sub
e.Graphics.Draw Image(Me.Backgr oundImage, Me.ClientRectan gle)
End Sub
If I do paste this code... where does the picture file information go?
"Jay B. Harlow [MVP - Outlook]" wrote:
Ron,
In addition to (instead of) handling the Paint event as Kevin showed, I
would consider overriding the OnPaintBackgrou nd method, as the
OnPaintBackgrou nd is the method that paints the background.

Something like:

Protected Overrides Sub OnPaintBackgrou nd(ByVal e As PaintEventArgs)
If Me.BackgroundIm age Is Nothing Then Exit Sub
e.Graphics.Draw Image(Me.Backgr oundImage, Me.ClientRectan gle)
End Sub

NOTE: You do not want (or need) to call MyBase.OnPaintB ackground as you
are
painting the entire background.

http://msdn.microsoft.com/library/de...roundtopic.asp

The following articles discusses the OnPaintBackgrou nd method:
http://msdn.microsoft.com/library/de...rmscontrol.asp

Hope this helps
Jay

"Ron Holmes" <vb**********@n oemail.nospam> wrote in message
news:A2******** *************** ***********@mic rosoft.com...
> Hi,
> Thank you for your reply. Yes, you have a complete understanding of my
> problem. I am a visual basic programmer and will have to study your C#
> code
> closely to see if I can glean a vb method to accomplish importing my
> image
> file using the OnPaint event. Thank you again for your response. Are
> you
> able
> to provide an example of this procedure in visual basic code? Thanks
> again.
>
> "Kevin Yu [MSFT]" wrote:
>
>> Hi,
>>
>> First of all, I would like to confirm my understanding of your issue.
>> From
>> your description, I understand that you need the background image size
>> to
>> be the same as client rectangle by stretching instead of tiling. If
>> there
>> is any misunderstandin g, please feel free to let me know.
>>
>> As far as I know, this cannot be implemented so simply as in VB6. We
>> can
>> try to override the OnPaint event to achieve this. When painting, we
>> just
>> use Graphics.DrawIm age to draw the particular bitmap to the client
>> area.
>> Here is an example:
>>
>> private void Form1_Paint(obj ect sender,
>> System.Windows. Forms.PaintEven tArgs e)
>> {
>> Bitmap b = new Bitmap(@"D:\My Documents\My Pictures\untitl ed.bmp");
>> e.Graphics.Draw Image(b,
>> this.ClientRect angle.X,this.Cl ientRectangle.Y ,this.ClientRec tangle.Width,
>> this.ClientRect angle.Height);
>> }
>>
>> HTH.
>>
>> Kevin Yu
>> =======
>> "This posting is provided "AS IS" with no warranties, and confers no
>> rights."
>>
>>


Jul 21 '05 #7
Thanks Kevin and Jay,
I finally get it. After reading the articles that Jay refered me to, It all
makes sense.
Kevins code makes sense as well as the code supplied by Jay.
You both are extremely knowledgeable.
When I become more knowledgeable, I think I will also share my hard learned
skills with others as you both, and others, are doing. I will take a lesson
from Jay, and direct the programmer to MSDN articles that describe in debth,
the principles involved. It brings me to mind, the old saying "You can give a
man a fish and feed him for a day, or you can teach him to fish and feed him
forever". (or something to that efect) smile...

Thanks guys.

"Jay B. Harlow [MVP - Outlook]" wrote:
Ron,
the Form1 background:

Form1.DefInstan ce.BackgroundIm age = System.Drawing. Image.FromFile( pix)


I would set BackgroundImage in the Load event with the following:
Me.BackgroundIm age = System.Drawing. Image.FromFile( pix)


Simply to ensure that all instances of the form have the property set.

and now I can't figure out how to call the Form1_Paint
procedure as the call wants an event as sender ( the e
variable in your code ).

You DO NOT call it as its a form level event, the form itself will call it
when it needs to be called.

VB (.NET, 1, 2, 3, 4, 5, 6) 101. Paint is an event handler for the form
itself, you need to select the Paint event from combo boxes at the top of
the editor to add a handler for the Paint event. Which will add a routine
such as:

Private Sub MainForm_Paint( ByVal sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs) Handles MyBase.Paint
' Kevin's code
End Sub

Alternatively you can override the OnPaint method, as the OnPaint method
raises the Paint event (this should have been explained in the link I gave).

' you can (and should) use the following instead of the above
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint( e) ' important this needs to be called!
' Kevin's code
End Sub

OnPaintBackgrou nd is only an overriden method.
Protected Overrides Sub OnPaintBackgrou nd(ByVal e As PaintEventArgs)
If Me.BackgroundIm age Is Nothing Then Exit Sub
e.Graphics.Draw Image(Me.Backgr oundImage, Me.ClientRectan gle)
End Sub


The paint event (Paint or OnPaint) & OnPaintBackgrou nd are automatically
called by the form itself when the form needs to be painted (when you or
windows calls Form.Update either directly or indirectly). This should also
have been explained in the link I gave.

You should only use Paint event or OnPaintBackgrou nd routine, not both.

Again the link I gave should explain when to use on or the other.

Hope this helps
Jay

"Ron Holmes" <vb**********@n oemail.nospam> wrote in message
news:8A******** *************** ***********@mic rosoft.com...
Please excuse my stupidity but I upgraded my vb6 program to

VS .NET 2003 and in my VB6 application, I stored the Form1

Background_Pict ure in my applications emts.ini file. During

the Form1 load event I use the following procedure to get

the backgroung picture location and file name:

In my VB6 BAS Module I have defined pix globally:

Public pix as string

'Procedure to Get the Form1.Picture from emts.ini

pix = VBGetPrivatePro fileString("Bac kground_Picture ",

"Path", "c:\Program Files\Holmes

Industries\Mega tech32\emts.ini ")

Next, I used the following procedure to load the file as

the Form1 background:

Form1.DefInstan ce.BackgroundIm age = System.Drawing. Image.FromFile( pix)

This caused the objectionable Tileing that I was

describing.

I placed the code that you so kindly sent me, into my

form1 Paint event and replaced the "D:\My Documents\My

Pictures\untitl ed.bmp" with the global value pix as shown

here:

Dim b As New System.Drawing. Bitmap("D:\My Documents\My

Pictures\untitl ed.bmp") AS

Dim b As New System.Drawing. Bitmap(pix)

and now I can't figure out how to call the Form1_Paint

procedure as the call wants an event as sender ( the e

variable in your code ).

e.Graphics.Draw Image(b, Me.ClientRectan gle.X, Me.ClientRectan gle.Y,
Me.ClientRectan gle.Width, Me.ClientRectan gle.Height)

I would like the background to load automatically during the form load
procedure but without the Tiling?????

Thank you for all of your help.
After 10 years of using VB3, VB4, VB5 and recently VB6, I never knew how
little I know about programming until I tried using VS .NET 2003. You are
suggestion I consider overriding the OnPaintBackgrou nd method and I am
realizing that I don't know how to do this. I know I am asking too much
but
this is very confusing. I wrote a very involved program to track equipment
maintenance problems. My VB6 application's executible is over 6 MB in size
and really works quite well and I never heard of any of this. What should
I
do next after the form1_Load code shown below?

'Procedure to Get the Form1.Picture from emts.ini

pix = VBGetPrivatePro fileString("Bac kground_Picture ", "Path", "c:\Program
Files\Holmes Industries\Mega tech32\emts.ini ")

Next, I used the following procedure to load the file as the Form1
background:

Form1.DefInstan ce.BackgroundIm age = System.Drawing. Image.FromFile( pix)

This is when the background Tiling appeared.

I think the RAD (Rapid Application Development) name is wishful thinking.
At
least until you learn the 10 thousand other things you never knew about,
while using the former languages. I admire you guys who have attained the
MVP
rating, and I know you know what I mean when I say this new language is
confusing. Thank you for replying to my cry for HELP!!!
Do I Paste the code below in the Form1_Paint event?

Protected Overrides Sub OnPaintBackgrou nd(ByVal e As PaintEventArgs)
If Me.BackgroundIm age Is Nothing Then Exit Sub
e.Graphics.Draw Image(Me.Backgr oundImage, Me.ClientRectan gle)
End Sub
If I do paste this code... where does the picture file information go?
"Jay B. Harlow [MVP - Outlook]" wrote:
Ron,
In addition to (instead of) handling the Paint event as Kevin showed, I
would consider overriding the OnPaintBackgrou nd method, as the
OnPaintBackgrou nd is the method that paints the background.

Something like:

Protected Overrides Sub OnPaintBackgrou nd(ByVal e As PaintEventArgs)
If Me.BackgroundIm age Is Nothing Then Exit Sub
e.Graphics.Draw Image(Me.Backgr oundImage, Me.ClientRectan gle)
End Sub

NOTE: You do not want (or need) to call MyBase.OnPaintB ackground as you
are
painting the entire background.

http://msdn.microsoft.com/library/de...roundtopic.asp

The following articles discusses the OnPaintBackgrou nd method:
http://msdn.microsoft.com/library/de...rmscontrol.asp

Hope this helps
Jay

"Ron Holmes" <vb**********@n oemail.nospam> wrote in message
news:A2******** *************** ***********@mic rosoft.com...
> Hi,
> Thank you for your reply. Yes, you have a complete understanding of my
> problem. I am a visual basic programmer and will have to study your C#
> code
> closely to see if I can glean a vb method to accomplish importing my
> image
> file using the OnPaint event. Thank you again for your response. Are
> you
> able
> to provide an example of this procedure in visual basic code? Thanks
> again.
>
> "Kevin Yu [MSFT]" wrote:
>
>> Hi,
>>
>> First of all, I would like to confirm my understanding of your issue.
>> From
>> your description, I understand that you need the background image size
>> to
>> be the same as client rectangle by stretching instead of tiling. If
>> there
>> is any misunderstandin g, please feel free to let me know.
>>
>> As far as I know, this cannot be implemented so simply as in VB6. We
>> can
>> try to override the OnPaint event to achieve this. When painting, we
>> just
>> use Graphics.DrawIm age to draw the particular bitmap to the client
>> area.
>> Here is an example:
>>
>> private void Form1_Paint(obj ect sender,
>> System.Windows. Forms.PaintEven tArgs e)
>> {
>> Bitmap b = new Bitmap(@"D:\My Documents\My Pictures\untitl ed.bmp");
>> e.Graphics.Draw Image(b,
>> this.ClientRect angle.X,this.Cl ientRectangle.Y ,this.ClientRec tangle.Width,
>> this.ClientRect angle.Height);
>> }
>>
>> HTH.
>>
>> Kevin Yu
>> =======
>> "This posting is provided "AS IS" with no warranties, and confers no
>> rights."
>>
>>


Jul 21 '05 #8
You're welcome. Thanks for sharing your experience with all the people
here. If you have any questions, please feel free to post them in the
community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1087
by: Jim Hubbard | last post by:
By true tiling I do not mean the Vertical tiling or horizontal tiling like .... 1 2 3 4 or
9
2822
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am facing. Please please help me to solve this as soon as possible. So here we go ... I am not able to take the screen shot of the windows form based "Smart
10
2060
by: Tyrant Mikey | last post by:
I don't know if this can even be done, but I'd REALLY like to eliminate the selection rectangle that appears around my ImageButton controls when the user clicks on them. The buttons are on a black background, and the selection rectangle looks like complete crap. Any suggestions are greatly appreciated!! Thanks!
8
388
by: Ron Holmes | last post by:
I want to place a background image on a windows form. Is there a way to prevent the image from Tiling without using an image box resized to the size of the form? I am using Visual Studio 2003 .NET. This is an easy thing to do in VB6.
3
9396
by: Sridhar | last post by:
Hi, I have created a user control which has the html code as follows <TABLE id="ToolBarTable" cellSpacing="0" cellPadding="0" width="100%" border="0"> <tr> <td align="right" bgColor="#000000"><IMG src="../Images/image1"> </td> </tr> <TR>
3
3243
by: Viken Karaguesian | last post by:
Hello all, I need somehelp with background tiling. I have a sneaking suspicion that what I want to do is not possible, but I'll ask anyway. :>) First some background: Here's the site in question: www.sayatnova.com (I'm sure many of you have seen this before as I've often asked for help). I've come a long way since I first created the site many moons ago and I'm trying to convert it to a (1) Table-less, (2) Frame-less and (3) Validated...
2
2284
by: Frankie | last post by:
Using SQL Server 2005 and .NET 2.0; I'm creating a Windows Forms application that will need to display photos of people, along with a bunch of information about each person. In a Web application, there is a generally accepted "best practice" of storing only a string (the path to the .jpg file name), with the actual file stored in an NTFS folder (and not in the database). What's the standard practice for Windows Forms applications? Is...
5
4013
by: ankit1999 | last post by:
I have a problem, everytime i'm run this page http://click2travel.in/index.php i get the this error,,,
5
13379
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the website URL before the image URL.
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.