Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I have a form with a background image. In the form is a user control. I have set the style of the user control to support transparent background. I have also set the color to be transparent. When the user control is drawn in the form, it sometimes show the image in the background fine,but other times, the image in the background is not lined up with the edges of the panel. It looks like the user control is holding on to a different rendition of the form background image that is slightly off centered.

 

Is there a way to make the image that is showing through the user control be exactly what is in the form background image? I am guessing I have to override the paint method, but the form should not be painting anything in the background, right?

 

Does'nt the child user control get invalidated when the parent form gets invalidated?

 

thanks

Bryan

Edited by bwells
  • *Gurus*
Posted

I don't think it does, necessarily. The behaviour you're describing is odd though, I haven't played too much with transparent backgrounds on usercontrols but from what I've heard it shouldn't misbehave like this.

 

One caveat of transparent backgrounds is that only the form background will show through - any other controls between the form and the control will not make a difference. Sorry I can't be more help on this.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

I found my problem. I was using a technique from this group to keep a background image sized the same as the form. I over-rode the paint method and drew the background image sized to be the correct size.

 

I dont understand why this caused the problem I was seeing, but if I make the image be the biggest possible size, then it works fine. I would like to use the suggestion to draw the image into a picture box and stretch the image that way, but my picture box ended up on top of all my controls. Is there a way to keep the picture at the bottom of the z order of my panels and controls in my form if I used a picture box instead of the background image on the form?

 

thanks

Bryan

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...