Home All Groups Group Topic Archive Search About

form's backgroundimage

Author
24 Jul 2006 5:08 AM
rodchar
hey all,

how do i change the BackgroundImage property of my form in code?

thanks,
rodchar

Author
24 Jul 2006 5:40 AM
Steven Nagy
Check MSDN help.
Its well documented.

rodchar wrote:
Show quoteHide quote
> hey all,
>
> how do i change the BackgroundImage property of my form in code?
>
> thanks,
> rodchar
Author
24 Jul 2006 12:45 PM
Herfried K. Wagner [MVP]
"rodchar" <rodc***@discussions.microsoft.com> schrieb:
> how do i change the BackgroundImage property of my form in code?

\\\
Me.BackgroundImage = ...
///

You can use 'Image.FromFile' to load a bitmap file, for example.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
24 Jul 2006 2:13 PM
rodchar
ok i took Steven's advice and found the same thing your showing:

Me.BackgroundImage = Image.FromFile("Untitled1.png")

i noticed however when i compile i just have a single executable which i
guess contains the current image. is there a way to keep it a single
executable when i want to add a 2nd image and switch between the two images
via mouse wheel event?



Show quoteHide quote
"Herfried K. Wagner [MVP]" wrote:

> "rodchar" <rodc***@discussions.microsoft.com> schrieb:
> > how do i change the BackgroundImage property of my form in code?
>
> \\\
> Me.BackgroundImage = ...
> ///
>
> You can use 'Image.FromFile' to load a bitmap file, for example.
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://classicvb.org/petition/>
>
Author
24 Jul 2006 2:53 PM
rodchar
also, i noticed it overlapped my first image. do i need to clear the
background first and then replace with my 2nd image?

Show quoteHide quote
"rodchar" wrote:

> ok i took Steven's advice and found the same thing your showing:
>
>  Me.BackgroundImage = Image.FromFile("Untitled1.png")
>
> i noticed however when i compile i just have a single executable which i
> guess contains the current image. is there a way to keep it a single
> executable when i want to add a 2nd image and switch between the two images
> via mouse wheel event?
>
>
>
> "Herfried K. Wagner [MVP]" wrote:
>
> > "rodchar" <rodc***@discussions.microsoft.com> schrieb:
> > > how do i change the BackgroundImage property of my form in code?
> >
> > \\\
> > Me.BackgroundImage = ...
> > ///
> >
> > You can use 'Image.FromFile' to load a bitmap file, for example.
> >
> > --
> >  M S   Herfried K. Wagner
> > M V P  <URL:http://dotnet.mvps.org/>
> >  V B   <URL:http://classicvb.org/petition/>
> >
Author
24 Jul 2006 8:24 PM
rodchar
I apologize for the confusion, let me rethink what i'm trying to do and
repost after i have a clearer understanding.

Show quoteHide quote
"rodchar" wrote:

> also, i noticed it overlapped my first image. do i need to clear the
> background first and then replace with my 2nd image?
>
> "rodchar" wrote:
>
> > ok i took Steven's advice and found the same thing your showing:
> >
> >  Me.BackgroundImage = Image.FromFile("Untitled1.png")
> >
> > i noticed however when i compile i just have a single executable which i
> > guess contains the current image. is there a way to keep it a single
> > executable when i want to add a 2nd image and switch between the two images
> > via mouse wheel event?
> >
> >
> >
> > "Herfried K. Wagner [MVP]" wrote:
> >
> > > "rodchar" <rodc***@discussions.microsoft.com> schrieb:
> > > > how do i change the BackgroundImage property of my form in code?
> > >
> > > \\\
> > > Me.BackgroundImage = ...
> > > ///
> > >
> > > You can use 'Image.FromFile' to load a bitmap file, for example.
> > >
> > > --
> > >  M S   Herfried K. Wagner
> > > M V P  <URL:http://dotnet.mvps.org/>
> > >  V B   <URL:http://classicvb.org/petition/>
> > >
Author
24 Jul 2006 10:51 PM
Steven Nagy
That would be a good idea.

If you want to be drawing multiple images all the time, a background
image or picturebox might not be the best option. There is an entire
namespace (System.Drawing) dedicated to drawing to surfaces. Generally,
most controls / forms have an OnPaint event where you can customise
what gets painted (drawn) to that surface

Also when changing images the way you are, its good to invalidate the
control/form.
Refresh is also an option, although may cause flicker.

Further topics found in MSDN if you search for GDI or GDI+.
Should be some walkthroughs for the OnPaint stuff.

rodchar wrote:
Show quoteHide quote
> I apologize for the confusion, let me rethink what i'm trying to do and
> repost after i have a clearer understanding.
Author
25 Jul 2006 12:30 AM
rodchar
thanks everyone for the help.

Show quoteHide quote
"Steven Nagy" wrote:

> That would be a good idea.
>
> If you want to be drawing multiple images all the time, a background
> image or picturebox might not be the best option. There is an entire
> namespace (System.Drawing) dedicated to drawing to surfaces. Generally,
> most controls / forms have an OnPaint event where you can customise
> what gets painted (drawn) to that surface
>
> Also when changing images the way you are, its good to invalidate the
> control/form.
> Refresh is also an option, although may cause flicker.
>
> Further topics found in MSDN if you search for GDI or GDI+.
> Should be some walkthroughs for the OnPaint stuff.
>
> rodchar wrote:
> > I apologize for the confusion, let me rethink what i'm trying to do and
> > repost after i have a clearer understanding.
>
>