Macapagal Galvez Emmanuel Macapagal Galvez Emmanuel - 2 months ago 17
Vb.net Question

Button Visible like relay

hi can you help me how to put 6 button in in a vb form but 1 private sub or whatever you need and make it hide and show each other when you move your mouse on it it is possible ? example when i point my mouse on button 1 the button 2 appear then when i point on button 2 the 3rd button appear and so on the other buttons

im new at vb.net
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.MouseMove,
Button2.MouseMove, Button3.MouseMove, Button4.MouseMove, Button5.MouseMove, Button6.MouseMove

Button1.Hide()
Button2.Show()
Button2.Hide()
Button3.Show()
Button3.Hide()
Button4.Show()
Button4.Hide()
Button5.Show()
Button5.Hide()
Button6.Show()
Button6.Hide()
Button1.Show()


End Sub
End Class

Answer

In the form load

 Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Button1.Show()
        Button2.Hide()
        Button3.Hide()
        Button4.Hide()
        Button5.Hide()
        Button6.Hide()
    End Sub

Then handle button mouse move event in one function call for all buttons as shown below. and write logic as shown below.

I wrote it for 3 buttons. You can plan for rest.

SCROLL below code to left see all button mouse move events handled.

Private Sub Button_MouseMove(sender As Object, e As    System.Windows.Forms.MouseEventArgs) Handles Button1.MouseMove, Button2.MouseMove, Button3.MouseMove, Button4.MouseMove, Button5.MouseMove, Button6.MouseMove
        If (Button1.Visible) Then
            Button1.Hide()
            Button2.Show()
            Exit Sub
        End If

        If (Button2.Visible) Then
            Button2.Hide()
            Button3.Show()
            Exit Sub
        End If
    End Sub