tags:

views:

186

answers:

0

Hi,

So here is my problem: I have a panel containing another panel. We'll call them outerPanel and innerPanel. Now I want to show a third panel on top of the innerPanel when the mouse enters the innerPanel. For that third panel, I have created a custom popup based on this thread. In InnerPanel, I have overridden the OnMouseEnter method

public class InnerPanel:Panel
{
     private PopupPanel popupPanel;

     public InnerPanel()
     {
        ...
        Panel thirdPanel = new Panel();
        ... // thirdPanel is initialised here, size, minimumSize, etc...
        popupPanel = new PopupPanel(thirdPanel);
        ...
     }
...
     protected override void OnMouseEnter(EventArgs e)
        {
            base.OnMouseEnter(e);
            popupPanel.Show(this, 0, 0);
        }
...
}

Here is what my PopupPanel class looks like

public class PopupPanel:ToolStripDropDown
{
    private Control _content;
    private ToolStripControlHost _host;

        public PopupCard(Control content)
        {
            //Basic setup...
            this.AutoSize = false;
            this.DoubleBuffered = true;
            this.ResizeRedraw = true;

            this._content = content;
            this._host = new ToolStripControlHost(content);

            //Positioning and Sizing
            this.MinimumSize = content.MinimumSize;
            this.MaximumSize = content.Size;
            this.Size = content.Size;
            content.Location = Point.Empty;

            //Add the host to the list
            this.Items.Add(this._host);
        }
}

The content parameter is the third panel and all its sizes are set before creating the popupPanel (size should be about (100,200)). Now when the mouse enters innerPanel, the popupPanel appears but the panel that it holds has its location set to 1,3 and its size set to 2,2. You can actually see a small square on the upper-left corner of the popup. I have no idea where those location and size come from. And they appear to be set during the call of show(). If anyone has a clue why this is happening, please let me know.

PS: I would like to have it done like this because there are different innerPanels in the outerPanel and they hold only a summary of information. When the mouse enters an innerPanel, the thirdPanel appears with more accurate information BUT if the thirdPanel is too big, I want it to display outside the boundaries of the outerPanel.