Hey!
Is it possible to slide a panel out of the actual form? Like you press a button then the panel slides all the way left and then out ? Then it should be able to come back too ?
Is this possible? Any ideas?
Printable View
Hey!
Is it possible to slide a panel out of the actual form? Like you press a button then the panel slides all the way left and then out ? Then it should be able to come back too ?
Is this possible? Any ideas?
Do you mean into the form, a la the Toolbox and other windows in VS, or do you out of the form?
try this:
Attachment 92853
That one worked Paul, it's also exactly what i'm looking for. But I have no idea how its working or even how to call it.
I suspect this is a custom panel control? Could you help me out a bit?
it is a custom panel control.
you need to add slideOutPanel.vb to your project, then after rebuilding you'll find slideOutPanel at the top of your toolbox + you add it just as any control.
to add controls to it at design time, resize it by dragging the border, + after resize it back to closedWidth.
when you run your project it should work as in my demo project
Is there any way to make it slide smoother? Thanks by the way.
try changing the timer interval + the line that sets the width values in tmr_tick
Okay I managed to modify the interval and the positions so it becomes smooth and nice. However I got another problem.
I put a button in the panel by dragging a button from the toolbox and putting it inside the panel on the designer. I highlighted the panel with my mouse, and the panel slided nice and smooth and the button showed up. However when i highlight the button inside the panel, the panel is closing :/
I also have a slide out panel example in the codebank, I have it set up in my signature.
ok. try this:
vb.net Code:
Imports System.Drawing.Drawing2D Public Class slideOutPanel Inherits Panel Dim polygon() As Point Dim closedWidth As Integer Dim maxWidth As Integer = 200 Dim caption As String = "Slide Out Panel" Dim closing As Boolean = False Private WithEvents tmr As New Timer Public Sub New() Me.Dock = DockStyle.Right Dim s As SizeF = Me.CreateGraphics.MeasureString(caption, Me.Font) Dim gp As New GraphicsPath polygon = New Point() {New Point(0, 0), New Point(300, 0), New Point(300, 300), New Point(CInt(s.Height), 300), New Point(CInt(s.Height), CInt(s.Width)), New Point(0, CInt(s.Width)), New Point(0, 0)} gp.AddPolygon(polygon) Me.Region = New Region(gp) closedWidth = CInt(s.Height) Me.Width = CInt(s.Height) polygon(2).X -= 1 polygon(3).Y -= 1 polygon(4).Y -= 1 polygon(5).Y -= 1 tmr.Interval = 100 add_handlers(Me) End Sub Private Sub add_handlers(ByVal c As Control) For Each ctrl As Control In c.Controls AddHandler c.MouseEnter, AddressOf handler If ctrl.Controls.Count > 0 Then add_handlers(ctrl) End If Next End Sub Private Sub handler(ByVal sender As Object, ByVal e As EventArgs) OnMouseEnter(e) End Sub Private Sub slideOutPanel_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint e.Graphics.DrawPolygon(Pens.Black, polygon) e.Graphics.TranslateTransform(closedWidth, 0) e.Graphics.RotateTransform(90) e.Graphics.DrawString(caption, Me.Font, Brushes.Black, 0, 0) e.Graphics.ResetTransform() End Sub Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs) closing = False tmr.Enabled = True MyBase.OnMouseEnter(e) End Sub Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs) closing = True tmr.Enabled = True MyBase.OnMouseLeave(e) End Sub Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick If closing Then Me.Width -= Math.Min(50, Me.Width - closedWidth) Else Me.Width += Math.Min(50, maxWidth - Me.Width) End If tmr.Enabled = If(Me.Width = closedWidth Or Me.Width = maxWidth, False, True) End Sub End Class
The same problem exists unfortunately Paul :/
I will take a look at yours soon dday9.
Thanks.
I liked your sliding control too dday9. It got no problems. However it is starting opened. Is there any way you can make it start closed?
i fixed the bugs in mine. sorry i couldn't help much earlier... been busy:
vb.net Code:
Imports System.Drawing.Drawing2D Public Class slideOutPanel Inherits Panel Dim polygon() As Point Dim closedWidth As Integer Dim captionHeight As Integer Dim maxWidth As Integer = 200 Dim caption As String = "Slide Out Panel" Dim closing As Boolean = False Private WithEvents tmr As New Timer Public Sub New() Me.Dock = DockStyle.Right Dim s As SizeF = Me.CreateGraphics.MeasureString(caption, Me.Font) Dim gp As New GraphicsPath polygon = New Point() {New Point(0, 0), New Point(300, 0), New Point(300, 300), New Point(CInt(s.Height), 300), New Point(CInt(s.Height), CInt(s.Width)), New Point(0, CInt(s.Width)), New Point(0, 0)} gp.AddPolygon(polygon) Me.Region = New Region(gp) closedWidth = CInt(s.Height) captionHeight = CInt(s.Width) Me.Width = CInt(s.Height) polygon(2).X -= 1 polygon(3).Y -= 1 polygon(4).Y -= 1 polygon(5).Y -= 1 tmr.Interval = 100 End Sub Private Sub slideOutPanel_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint e.Graphics.DrawPolygon(Pens.Black, polygon) e.Graphics.RotateTransform(270) e.Graphics.DrawString(caption, Me.Font, Brushes.Black, -captionHeight, 0) e.Graphics.ResetTransform() End Sub Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs) closing = False tmr.Enabled = True MyBase.OnMouseEnter(e) End Sub Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs) Dim p As Point = Me.PointToClient(Cursor.Position) If Not Me.Region.IsVisible(p) Then closing = True tmr.Enabled = True End If MyBase.OnMouseLeave(e) End Sub Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick If closing Then Me.Width -= Math.Min(50, Me.Width - closedWidth) Else Me.Width += Math.Min(50, maxWidth - Me.Width) End If tmr.Enabled = If(Me.Width = closedWidth Or Me.Width = maxWidth, False, True) End Sub End Class
Thank you, that solved all the bugs :)
I know this thread is quite old, but is it possible to make it slide from the left instead of the right?
Thanks
LB
Start a new thread!
Take a look at this contribution I made: http://www.vbforums.com/showthread.p...ols&highlight=