How do we overlay and use transparency in User Controls in VB.Net 2005

Posted on 2007-10-19
Last Modified: 2013-12-20
[ To help explain this problem, we have created some screen dumps - but EE doesn't seem to allow us to paste them in here, so I have stored them elseehere and posted URL's to them ]

We have a windows form control (in our case a MDI sub form). We want to put user controls on that form. These user controls can and will overlap, in fact each control overlays the previous control. We want the previous control to show through AND allow use of the underlaying controls  controls.

So a form might contain 2 controls all of which should be visible and usable.

See screenshot for example :

This form contains two controls usercontrol1 and usercontrol2. In the illustration above usercontrol1 overwrites usercontrol2 preventing usercontrol2 from being used. We want usercontrol1 to be transparent AND we want to be able to use the controls on usercontrol12 even though usercontrol1 overlays usercontrol2.


The controls on the form will be built up in layers thus :-
So this is our initial form with one usercontrol placed on it ( )

This is after user control1 has been put on the form now we add usercontrol2 which overlays usercontrol1 and in our case it not only obscures usercontrol1 but also prevents use of the usercontrol1.button2 button.

Now we add another usercontrol(3) and again we want to (see and) use the controls on usercontrol1 and usercontrol2 underneath (as well as the controls on usercontrol3).

There appears to be two main issues:-

1) Providing transparency.
2) Allowing access to the overlapped controls.

We have tried using the various transparency settings provided by .NET.

Setting SupportsTransparentBackColor to true, UserPaint to False and setting the backcolor to transparent does provide a kind of transparency however we then run into painting issues  snippets of previous screen data left from previous screens.

Additionally we are still unable to use any of the controls that appear underneath an overlapped control.

Also tried using             'MyBase.BackColor = Color.FromArgb(65, 204, 212, 230)

But this just allows you to alter the degree of transparency.





Question by:e_bigchris
    LVL 25

    Accepted Solution

    I may be wrong, but I am thinking that the only way to make this happen from one control to another would be by capturing all messages on the top most control and using SendMessage API to feed them to the control underneath it. As for transparency, this obviously works by painting control one with alpha channel, or, by setting control one's background to what is painted on the parts of control2 that are in under control1. Either way is a lot of work.  I have found that for drawing apps, Double Buffering should be turned on. Also, a call to .Refresh is often necessary for things to repaint correctly.  Graphics are NOT very fast in .NET

    A great GDI+ resource is found at:

    Sorry I can't help you more.
    LVL 1

    Expert Comment

    Forced accept.

    EE Admin

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now