Here, I'm going to tell you how I'm creating sliding/floating panel for your Windows application in C#. It's a very simple technique. Try it if you like it...
Using the Code
Follow these steps:
- Start a Windows Form application
- Add a panel (eg:
Panel1) and dock it
- Place two button controls (e.g.:
Button2) inside the panel and dock it to left & right of the
- Place another panel (e.g.:
Panel1 and set
dockstyle as "
- Add a "User Control Form" (e.g.:
UserControl1) to your project and place all your controls on it (e.g.:
- Add two
Timer controls to your project (e.g.:
timer2) & set
Interval = 5.
- Finally, write the code as shown below:
public partial class Form1 : Form
UserControl usrCtrl = new UserControl1();
private void Form1_Load(object sender, EventArgs e)
usrCtrl.Left = usrCtrl.Top = 0;
private void button1_MouseDown(object sender, MouseEventArgs e)
private void button1_MouseUp(object sender, MouseEventArgs e)
private void button2_MouseDown(object sender, MouseEventArgs e)
private void button2_MouseUp(object sender, MouseEventArgs e)
private void timer1_Tick(object sender, EventArgs e)
if (usrCtrl.Left < 0)
usrCtrl.Left = usrCtrl.Left + 5;
private void timer2_Tick(object sender, EventArgs e)
if (usrCtrl.Right >= panel2.Left + panel2.Width)
usrCtrl.Left = usrCtrl.Left - 5;
Thank you for using my tricks.
He is a Commerce Graduate and working as an Accountant. He learned Programming because of his passion and craze. He is a beginner in .NET. His favourite language is C# and favourite database is MySQL.
He loves playing guitar and listening to music.