473,387 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

User Controls transparent

I'm using VS 2003, C#.Net 2003.

I built a simple windows form app. with the following attributes:
- has a BackgroundImage set to a jpeg

I built a very simple user control that contains a picture box set to an
icon. The UserControl constructor sets
SetStyle( ControlStyles.SupportTransparentBackColor, true);
this.BackColor = Color.Transparent;
The control does nothing except display the icon.

In the main windows form, on formload event, I declare and instantiate 30
user controls and give them various locations on the main form.

The Problem: When the main form loads, displays or becomes active, there
are transparent (to the desktop) rectangles in locations where the user
controls are to be displayed. The transparent rectangles then fill in with
the mainform background image and the icons in the usercontrol.

I have identified this issue to be linked the BackColor = Color.Transparent.
If I set the BackColor to a color, this issue goes away. Offcourse, I now
have a solid box around my control

Is there a way keep the usercontrol backgroud transparent while eliminating
this annoying transparent rectangle issue?

Mar 7 '06 #1
1 3021
We have been having similar problems in our application when the form
has a number of controls. This behavior is caused by how .NET handles
painting. Each parent will only paint its area not obscured by child
controls. So, the Form won't paint behind the UserControls after they
are added to the Controls collection of the Form. The reason why you
don't see the transparent rectangles if you set their background color
is that their PaintBackground event will fill the area with their
BackColor property. If it is transparent, nothing will be drawn in
that rectangle until the UserControl's Paint event is fired.

We found that it helps, but does not eliminate, to call Refresh() when
the form is shown. Since you are adding the controls during the
FormLoad event, try calling Refresh() before adding the controls. This
will force the form to repaint itself, and won't leave space for the
controls. While the UserControls won't be painted immediately (you
will probably see them rapidly appear on the screen, just not at once),
you at least won't see "holes" in your Form.

Hope this helps.
Abe

Mar 8 '06 #2

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

Similar topics

6
by: Tom | last post by:
why doesn't user control support transparent ? even after you programmatically make it transparent the controls that you add on it still doesn't transparency where they normally would in a winform...
4
by: Benny | last post by:
Hello experts, How can i set windows form controls (i.e. button, label, ...etc) to transparent? I tried set the control back colour property to transparent, but it still appear non-transparent....
7
by: Chuck | last post by:
I am working in C# 2003. Can anyone tell me how to make a user control transparent. VS help doesn't help. What I want to do is draw on a user control during design time and then place the...
1
by: Efkas | last post by:
My application have some level : 1. MyButton class with Label inheritance 2. MyComponent as User Control loading and positionning some of MyButtons 3. MyApp loading and positionning MyComponent ...
4
by: Efkas | last post by:
Hi, I had some label with BackColor.Transparent and a User Control also with transparent background. When I put a label on the user control, instead to have transparent result I obtain a...
4
by: Nad | last post by:
Hello, I have a user control that has a button and a Calendar. Once you click on the button I display the calendar. Now when I move this user control to a web form, once I click on this button...
1
by: jboldrick | last post by:
I'm using Access 2003. I seem to have suddenly lost the ability to set the Back Style property of tab controls to "Transparent." Or rather, I can set the property value as "Transparent" but nothing...
0
by: FredC | last post by:
I'm using VS C#.Net 2003. I built a simple windows form app. with the following attributes: - has a BackgroundImage set to a jpeg I built a very simple user control that contains a picture box set...
0
by: MasterOfTheDark | last post by:
This one's a hairy one to explain. What I've got is a class called "VistaGroupBox" that I put some nice-looking Vista-style gradients in the background and made to look like the ribbon categories...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.