dcsimg
Results 1 to 7 of 7

Thread: Form will not show background image

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,259

    Form will not show background image

    I had this working earlier, but now it's not. I decided I was going to throw the code away (and I did) and now I'm trying to make it work again (and it's not).

    I'm using:
    Code:
    DesktopWindow.BackgroundImage = Image.FromFile(PathToImageFile)
    I've tried this from several places in the code and it won't work. Anyone come across this before? I'm afraid I haven't. That's just one of those things that work!

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,025

    Re: Form will not show background image

    Have you tested whether Image.FromFile is returning a valid Image?

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,259

    Re: Form will not show background image

    Yes, I put a breakpoint where I can see the filename and it's valid. I tested with a picturebox on the form and it showed the image just fine. Used the same code, just different control

  4. #4
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    5,080

    Re: Form will not show background image

    Are you doing anything odd in your paint event, like filling the form with a solid color?

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,259

    Re: Form will not show background image

    Never mind Jmc. This is another one of those weird things that seem to happen to me for no reason that I can tell. I just created a new form and changed the BackgroundImage just fine. Maybe I can slowly bring that one up to where the older version is and it will work.

    Thanks for the help

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,025

    Re: Form will not show background image

    Have you set IsMdiContainer to True? If you have then your form contains an MdiClient control that covers it completely. That's why the form changes colour when you set that property. In that case, you would have to display your Image on that rather than the form, which can only be done in code. To learn how to access that control, check out my CodeBank thread here:

    http://www.vbforums.com/showthread.php?496227

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,259

    Re: Form will not show background image

    Are you doing anything odd in your paint event, like filling the form with a solid color?
    Hi Passel. Not doing a thing in paint. I just created the form a bit ago and I haven't changed much about it. Then about 5 minutes ago I tried it with a new form and it worked fine. But I would love to know what I did to make it stop working. I has to be in code because the only thing I really did with the form was set border type to "none" and set a background image. That's it.

    Have you set IsMdiContainer to True? If you have then your form contains an MdiClient control that covers it completely. That's why the form changes colour when you set that property. In that case, you would have to display your Image on that rather than the form, which can only be done in code. To learn how to access that control, check out my CodeBank thread here:
    That's a no on the Midi Container. I never use them so I don't even seeing me do it by mistake. And like I said to Passel, I'm going to see if I can get this new form to work and see how that goes. Right now is down time for me and I'm taking a break

    Both of you have a great night and thank you for your help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width