CODe
CODe

Reputation: 2301

C# way to implement vertical auto-hiding tool bar

What I'm attempting to create is very similar to the "Toolbox" in VS 2008 and VS 2010. It will be on the left side of my MDI parent, and will pop out when the user hovers their mouse over it. Again, this is just like the VS Toolbox.

My question is what is the best way to implement this? Please keep in mind I am putting this on the left side of a MDI parent and am using VS 2008, C#, and .NET 3.5. In addition, I plan on putting a TreeView inside the toolbar, so whatever is used must support the addition of a TreeView object.

Thanks!

Upvotes: 3

Views: 7086

Answers (2)

Dirk Strauss
Dirk Strauss

Reputation: 657

Take a look at the DockPanel Suite on SourceForge. I have seen many Custom Controls on the web trying to mimic the VS Toolbar, but none work as well as this one does. It has a high user rating also.

Upvotes: 1

CODe
CODe

Reputation: 2301

A vertical auto-hiding toolbar, from what I've gathered online and by testing, is best implemented with a ToolStrip object, docked to the left in my case. To give the appearance of a TreeView object popping out of that, add a ToolStripButton. Then, add a MouseHover Event to the ToolStripButton that makes a Panel object (that is docked to the left as well) visible. Obviously, it would be best to make the Panel object invisible by default. Then, add a MouseLeave event for the Panel so when the user leaves the Panel, the Panel then becomes invisible again or "pops" back in.

It doesn't have the nice effect of it popping out like Visual Studio 2008/2010 does, but it has the basic functionality that I need.

Here is the code for the MouseHover and MouseLeave events. Very simple.

    private void openPanel1ToolStripButton_MouseHover(object sender, EventArgs e)
    {
        if(panel1.Visible == false)
        {
            panel1.Visible = true;
        }
    }

    private void panel1_MouseLeave(object sender, EventArgs e)
    {
        if (panel2.Visible == true)
        {
            panel2.Visible = false;
        }
    }

Upvotes: 2

Related Questions