German Wear Discount Shop - Click Here Write for Dotnet-friends and earn for your each submission [Dot]Net-Friends
Skip Navigation Links
Home
Latest
Fast Code
Articles
Tutorials
Online Resources
Forums
Login   | Hi, Guest


How to create a Transparent Panel Control in .NET?
Written By Omer Kamal On 31/01/2008

There are situations when we need right click or mouse double click Client side events there we need a control which gives us a layer effect without showing itself. A transparent Panel is a nice and some time a unique solution for this.

Views: 1114
Rating: 5
Login to Rate
omerkamal
Tagged Under: GDI, User/Custom Controls, Web Controls

Explanation:

Some days ago I was creating a Filter Control for our Analysis Reports in the web portal. I was supposed to create a window on the right click of the mouse so it can extract all Cubes and the Hirarechies lists for the purpose of selecting the Filtering Nodes.

The only way out which I thought was to create a Transparent panel as a base for the right click. Following was the way it worked for me.

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7.  
  8. namespace WebBrowserAutomation
  9. {
  10.     ///
  11.     /// A transparent control.
  12.     ///
  13.     public class TransparentPanel : Panel
  14.     {
  15.         public TransparentPanel()
  16.         {
  17.         }
  18.  
  19.         protected override CreateParams CreateParams
  20.         {
  21.             get
  22.             {
  23.                 CreateParams createParams = base.CreateParams;
  24.                 createParams.ExStyle |= 0x00000020;
  25.                 return createParams;
  26.             }
  27.         }
  28.  
  29.         protected override void OnPaintBackground(PaintEventArgs e)
  30.         {
  31.             // Leave the background unpainted
  32.         }
  33.     }
  34. }

 

Delicious Digg reddit reddit Technorati
About the Author:

@@ Omer Kamal is a Software Developer at Elanize KG Germany. He MSc. Mathematics from Islamia University Bahawalpur, Pakistan and Certified Developer from National Institute of Electronics Islamabad, Pakistan. He is Founder of FriendsPoint.de and Dotnet-Friends.com. He is currently Involved with Microsoft Office SharePoint 2007, Microsoft Dynamics CRM, BI Portal Solutions (Microsoft Dynamics Customization) and Web Security Solutions.
Check Omer Kamal Profile

Related Useful Links:
Visitors/Readers Comments
(for questions please use The Forum)



"Be the First to Comment!"


Add your Comments

Name:  
Message:
Note: For faster response please use Forums >> for your questions instead of the comments area! (Admin)