Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I create a menu that has auto show/hide .for example on mouse
hover auto show softly and on mouse leave auto hide;
Like Toolbox window in VisualStudio ,you know when you set the pin to
auto hide it hides on mouse_leave . :)
please explain completely or gimme a link. :rose:
Posted

You no need to create your own instead you can do it with menustrip also

you have to use threading for that

may this code useful to you

C#
private void Form1_MouseMove(object sender, MouseEventArgs e)
       {
            if (e.y < 40)
            {
                this.BeginInvoke((ThreadStart)delegate()
                {
                    MenuShow();

                });
            }
            else if (e.y > 100)
            {

                this.BeginInvoke((ThreadStart)delegate()
                {
                    MenuHide();

                });

            }
        }

        private void MenuShow()
        {
            while (menuStrip1.Top != 0)
            {

                menuStrip1.Top++;
                Thread.Sleep(10);
                menuStrip1.Update();
            }
        }

        private void MenuHide()
        {
            while (menuStrip1.Top != -25)
            {
                menuStrip1.Top--;
                Thread.Sleep(10);
            }
        }
 
Share this answer
 
v2
Hey try this Code, this will work for you.............!!!

C#
private void Form1_MouseMove_1(object sender, MouseEventArgs e)
{
    if (e.Y == 10)
    {
        menuStrip1.Visible = true;
    }
    else if (e.Y > 20)
    {
        menuStrip1.Visible = false;
    }
}


Thanks N Regards,
ASHISH V K
 
Share this answer
 
well done khaniya but you forget somthing something ,you must change
a little this code :

private void Form1_MouseMove(object sender, MouseEventArgs e)
       {


           if (e.Y > 40)
           {
               this.BeginInvoke((ThreadStart)delegate()
               {
                   MenuShow();

               });
           }
           else if (e.Y < 100)
           {

               this.BeginInvoke((ThreadStart)delegate()
               {
                   MenuHide();

               });

           }
       }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900