How to Create a Drop Down Menu in C#
Project Source Code :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Drop_Down_Menu : Form
{
public Drop_Down_Menu()
{
InitializeComponent();
}
int t1 = 45;
int t2 = 45;
int t3 = 45;
private void button1_MouseHover(object sender, EventArgs e)
{
this.panel2.Size = new Size(this.panel2.Size.Width, t2);
this.panel3.Size = new Size(this.panel3.Size.Width, t3);
timer1.Start();
}
private void button1_MouseLeave(object sender, EventArgs e)
{
timer1.Stop();
t1 = 45;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (t1 > 225)
{ timer1.Stop(); }
else
{
this.panel1.Size = new Size(this.panel1.Size.Width, t1);
t1 += 5;
}
}
private void timer2_Tick(object sender, EventArgs e)
{
if (t2 > 225)
{ timer2.Stop(); }
else
{
this.panel2.Size = new Size(this.panel2.Size.Width, t2);
t2 += 5;
}
}
private void timer3_Tick(object sender, EventArgs e)
{
if (t3 > 225)
{ timer3.Stop(); }
else
{
this.panel3.Size = new Size(this.panel3.Size.Width, t3);
t3 += 5;
}
}
private void button10_MouseHover(object sender, EventArgs e)
{
this.panel1.Size = new Size(this.panel1.Size.Width, t1);
this.panel3.Size = new Size(this.panel3.Size.Width, t3);
timer2.Start();
}
private void button10_MouseLeave(object sender, EventArgs e)
{
timer2.Stop();
t2 = 45;
}
private void button15_MouseHover(object sender, EventArgs e)
{
this.panel1.Size = new Size(this.panel1.Size.Width, t1);
this.panel2.Size = new Size(this.panel2.Size.Width, t2);
timer3.Start();
}
private void button15_MouseLeave(object sender, EventArgs e)
{
timer3.Stop();
t3 = 45;
}
private void Drop_Down_Menu_MouseHover(object sender, EventArgs e)
{
this.panel1.Size = new Size(this.panel1.Size.Width, t1);
this.panel3.Size = new Size(this.panel3.Size.Width, t3);
this.panel2.Size = new Size(this.panel2.Size.Width, t2);
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Drop_Down_Menu : Form
{
public Drop_Down_Menu()
{
InitializeComponent();
}
int t1 = 45;
int t2 = 45;
int t3 = 45;
private void button1_MouseHover(object sender, EventArgs e)
{
this.panel2.Size = new Size(this.panel2.Size.Width, t2);
this.panel3.Size = new Size(this.panel3.Size.Width, t3);
timer1.Start();
}
private void button1_MouseLeave(object sender, EventArgs e)
{
timer1.Stop();
t1 = 45;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (t1 > 225)
{ timer1.Stop(); }
else
{
this.panel1.Size = new Size(this.panel1.Size.Width, t1);
t1 += 5;
}
}
private void timer2_Tick(object sender, EventArgs e)
{
if (t2 > 225)
{ timer2.Stop(); }
else
{
this.panel2.Size = new Size(this.panel2.Size.Width, t2);
t2 += 5;
}
}
private void timer3_Tick(object sender, EventArgs e)
{
if (t3 > 225)
{ timer3.Stop(); }
else
{
this.panel3.Size = new Size(this.panel3.Size.Width, t3);
t3 += 5;
}
}
private void button10_MouseHover(object sender, EventArgs e)
{
this.panel1.Size = new Size(this.panel1.Size.Width, t1);
this.panel3.Size = new Size(this.panel3.Size.Width, t3);
timer2.Start();
}
private void button10_MouseLeave(object sender, EventArgs e)
{
timer2.Stop();
t2 = 45;
}
private void button15_MouseHover(object sender, EventArgs e)
{
this.panel1.Size = new Size(this.panel1.Size.Width, t1);
this.panel2.Size = new Size(this.panel2.Size.Width, t2);
timer3.Start();
}
private void button15_MouseLeave(object sender, EventArgs e)
{
timer3.Stop();
t3 = 45;
}
private void Drop_Down_Menu_MouseHover(object sender, EventArgs e)
{
this.panel1.Size = new Size(this.panel1.Size.Width, t1);
this.panel3.Size = new Size(this.panel3.Size.Width, t3);
this.panel2.Size = new Size(this.panel2.Size.Width, t2);
}
}
}
=> OutPut :
C# Drop Down Menu |
Download Projects Source Code