locked
CONTROL HIDE & TIME DELAY RRS feed

  • Question

  • HI

    Use the next CLASS   and put in the buttons

    1- What is lost is when the focus is lost on the PANEL or the buttons are hidden
    2- Second, add time to its appearance 5000

    I added this procedure but nothing happens

    OnLostFocus

    CLASS'

    Public Class PANELMENUE
        Inherits System.Windows.Forms.Panel
    
        Public Sub New()
            MyBase.New()
    
        End Sub
    
        Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
            MyBase.OnPaint(e)
            Dim borderWidth As Integer = 1
            ControlPaint.DrawBorder(e.Graphics, Me.ClientRectangle, Color.LightGray, ButtonBorderStyle.Solid)
    
        End Sub
    
        Protected Overrides Sub OnResize(ByVal eventargs As EventArgs)
            MyBase.OnResize(eventargs)
            Me.Invalidate()
        End Sub
    
        Protected Overrides Sub OnLostFocus(ByVal e As EventArgs)
            MyBase.OnLostFocus(e)
            Me.Dispose()
        End Sub
    
    End Class
    

    Saturday, September 1, 2018 1:57 PM

Answers

  • Hi,

    Do you want to hide the panel when the panel loses focus?

    code:

    Public Class Form1
        Public Class PANELMENUE
            Inherits System.Windows.Forms.Panel
    
            Public Sub New()
                MyBase.New()
            End Sub
    
            Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
                MyBase.OnPaint(e)
                Dim borderWidth As Integer = 1
                ControlPaint.DrawBorder(e.Graphics, Me.ClientRectangle, Color.LightGray, ButtonBorderStyle.Solid)
                Me.BackColor = Color.Black
    
            End Sub
    
            Protected Overrides Sub OnResize(ByVal eventargs As EventArgs)
                MyBase.OnResize(eventargs)
                Me.Invalidate()
            End Sub
            Protected Overrides Sub OnLeave(ByVal e As EventArgs)
                MyBase.OnLeave(e)
                Dim t As New Timer With {.Interval = 2000, .Enabled = True}
                AddHandler t.Tick, Sub()
                                       t.Stop()
                                       Me.Hide()
                                   End Sub
            End Sub
        End Class
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim leo As PANELMENUE = New PANELMENUE
            Me.Controls.Add(leo)
            leo.Controls.Add(TextBox1)
        End Sub
    End Class

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ahmeddc Tuesday, September 4, 2018 12:26 AM
    Monday, September 3, 2018 6:16 AM
  • Try OnLeave instead of OnLostFocus.

    For time-related features, try a Timer:

       Public Sub New()

          MyBase.New()

     

          Dim t As New Timer With {.Interval = 5000, .Enabled = True}

          AddHandler t.Tick, Sub()

                                t.Stop()

                                Me.Hide()

                             End Sub

       End Sub


    • Marked as answer by ahmeddc Tuesday, September 4, 2018 2:55 AM
    Saturday, September 1, 2018 5:20 PM

All replies

  • Try OnLeave instead of OnLostFocus.

    For time-related features, try a Timer:

       Public Sub New()

          MyBase.New()

     

          Dim t As New Timer With {.Interval = 5000, .Enabled = True}

          AddHandler t.Tick, Sub()

                                t.Stop()

                                Me.Hide()

                             End Sub

       End Sub


    • Marked as answer by ahmeddc Tuesday, September 4, 2018 2:55 AM
    Saturday, September 1, 2018 5:20 PM
  • Try OnLeave instead of OnLostFocus.

    For time-related features, try a Timer:

       Public Sub New()

          MyBase.New()

     

          Dim t As New Timer With {.Interval = 5000, .Enabled = True}

          AddHandler t.Tick, Sub()

                                t.Stop()

                                Me.Hide()

                             End Sub

       End Sub


    I was happy to follow up on my topic
    There is a problem executing the requested
    The time code you set works once when you open the form for the first time only
    I changed the procedure as
    I said OnLeaveand it does not work either
    • Marked as answer by ahmeddc Tuesday, September 4, 2018 12:26 AM
    • Unmarked as answer by ahmeddc Tuesday, September 4, 2018 2:54 AM
    Saturday, September 1, 2018 5:54 PM
  • Hi,

    Do you want to hide the panel when the panel loses focus?

    code:

    Public Class Form1
        Public Class PANELMENUE
            Inherits System.Windows.Forms.Panel
    
            Public Sub New()
                MyBase.New()
            End Sub
    
            Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
                MyBase.OnPaint(e)
                Dim borderWidth As Integer = 1
                ControlPaint.DrawBorder(e.Graphics, Me.ClientRectangle, Color.LightGray, ButtonBorderStyle.Solid)
                Me.BackColor = Color.Black
    
            End Sub
    
            Protected Overrides Sub OnResize(ByVal eventargs As EventArgs)
                MyBase.OnResize(eventargs)
                Me.Invalidate()
            End Sub
            Protected Overrides Sub OnLeave(ByVal e As EventArgs)
                MyBase.OnLeave(e)
                Dim t As New Timer With {.Interval = 2000, .Enabled = True}
                AddHandler t.Tick, Sub()
                                       t.Stop()
                                       Me.Hide()
                                   End Sub
            End Sub
        End Class
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim leo As PANELMENUE = New PANELMENUE
            Me.Controls.Add(leo)
            leo.Controls.Add(TextBox1)
        End Sub
    End Class

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ahmeddc Tuesday, September 4, 2018 12:26 AM
    Monday, September 3, 2018 6:16 AM