BP Forums
Sliding Animation - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+----- Forum: Programming Help (https://bpforums.info/forumdisplay.php?fid=9)
+----- Thread: Sliding Animation (/showthread.php?tid=462)



Sliding Animation - zmanalpha - 02-19-2012

Hi There, I Am Trying to make a control(Panel)slide down from the top of a window, but I can't get it to work for the life of me... Anyone have an idea?


Re: Sliding Animation - brandonio21 - 02-20-2012

This code assumes that your Panel is called PNL.

So, here's the basic idea. You want to add a timer to your form with the interval of around 50. Then, insert something like this code.

Code:
Sub hover() handles PNL.MouseEnter
  Timer2.Stop()
  Timer2.Enabled = False
  Timer1.Start()
  Timer1.Enabled = True
End Sub

Sub leave() handles PNL.MouseLeave
  Timer1.Stop()
  Timer1.Enabled = False
  Timer2.Start()
  Timer2.Enabled = True
End Sub

Sub OpenTimerTick handles Timer1.Tick
If PNL.Height < 150
   PNL.Height += 5
End If
End Sub

Sub CloseTimerTick handles Timer2.Tick
If PNL.Height > 0
   PNL.Height -= 5
End If
End Sub

Hopefully this helps. Please note that there may be better ways to do this (Like using only one timer), but I just wrote down the first way that came to mind!


Re: Sliding Animation - zmanalpha - 02-20-2012

Thanks Alot! This Helps Greatly!


Re: Sliding Animation - brandonio21 - 02-20-2012

Hey, no problem!