1

I'm trying to show a popup when clicking on a cell in a grid. The popup has a usercontrol which contains an Element Host. I'm trying to make the popup transparent so I can see whats on the grid beneath but it doesn't seem to work. I'm using a ToolStripDropDown to show the popup.

Here is my code for the popup

ToolStripDropDown popup = new ToolStripDropDown();
popup.BackColor = Color.Transparent;
UserControl2 userControl = new UserControl2(popup);
userControl.Show();
popup.Margin = Padding.Empty;
popup.Padding = Padding.Empty;
ToolStripControlHost host = new ToolStripControlHost(userControl);
host.BackColor = Color.Transparent;
host.Margin = Padding.Empty;
host.Padding = Padding.Empty;
popup.Items.Add(host);

and here is the code for the UserControl itself

public partial class UserControl2 : UserControl
{
    private ToolStripDropDown popup;
    public UserControl2(ToolStripDropDown toolStrip)
    {
        InitializeComponent();
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
        this.BackColor = Color.Transparent;
        popup = toolStrip;

        this.elementHost1.BackColorTransparent = true;
    }
}

and this is the resultenter image description here

Can someone tell what I'm doing wrong here, is there any way to show a transparent popup. The popup will eventually host a transparent WPF Control.

Thanks.

gatordude
  • 69
  • 3
  • 8
  • Making a top-level window transparent requires using the TransparencyKey property in Winforms. In case it needs to be said, if you do that with the window you showed in your screenshot then you'll have a problem: you won't see it at all. Use the Opacity property to make it partially transparent. – Hans Passant Mar 04 '14 at 22:14
  • I'm trying to make the UserControl transparent. Is there an Opacity property for the UserControl ? – gatordude Mar 05 '14 at 12:52

0 Answers0