Windows Develop Bookmark and Share   
 index > Windows Forms General > MDI Container Event Firing
 

MDI Container Event Firing

I have a panel on an MDI form. I want it to behave the same as thepanelsin Visual Studio (ie Solution explorer).

The panel expands correctyandI can pin it.

If I move the mouse into the Toolbar (ie off the panel) it collapses as expected if it is not pinned.

However, when move the mouse off the expanded, unpinned panel onto the MDI canvas, the panel does not collapse. It appears that events on the canvas are not hooked up. How can I achieve this? I would have thought that a MouseEnter event would fire when moving the mouse onto the canvas?

GrantS  Saturday, May 26, 2007 11:40 PM
Don't you need a MouseLeave event? It reliably fires when I move the mouse into the MDI client window. Getting a MouseEnter for the MDI client window is a bit difficult, that window is not readily accessible. You could do it like this:

private void Form1_Load(object sender, EventArgs e) {
foreach (Control ctl in this.Controls)
if (ctl is MdiClient) {
ctl.MouseEnter += MdiClientMouseEnter;
break;
}
}
private void MdiClientMouseEnter(object sender, EventArgs e) {
Console.WriteLine("mdi client entered");
}

nobugz  Sunday, May 27, 2007 11:59 AM
Don't you need a MouseLeave event? It reliably fires when I move the mouse into the MDI client window. Getting a MouseEnter for the MDI client window is a bit difficult, that window is not readily accessible. You could do it like this:

private void Form1_Load(object sender, EventArgs e) {
foreach (Control ctl in this.Controls)
if (ctl is MdiClient) {
ctl.MouseEnter += MdiClientMouseEnter;
break;
}
}
private void MdiClientMouseEnter(object sender, EventArgs e) {
Console.WriteLine("mdi client entered");
}

nobugz  Sunday, May 27, 2007 11:59 AM

Genius nobugz!

Thanks, this worked perfectly.

GrantS  Monday, May 28, 2007 5:09 PM

You can use google to search for other answers

Custom Search

More Threads

• Generalized Edit Menu w/ Undo/Redo, Cut/Copy/Paste
• title bar+c#
• New IE Window
• Application looses focus after a dialog is closed
• What is the event when click a 'non-modal' form
• events are fired but the form looks frozen
• WebBrowser embedded resources
• WebBrowser print properties
• How do I drag a document hyperlink from Internet Explorer to a Windows Form control?
• Combobox stability problem???