hello!
i need help with mouse click.
i need to place in a timer_tick a code that detect if i clicked with the mouse.
so i know that i can use on mouse click event ,but i have many and many controls so it's take a lot of time and code so simply and for me it's the hard thing,i want to detect if the mouse had been clicked or not.
so thank you for help!:)

Hi,

You doesn't need a timer for this.
Here's an example:

Private Sub Form1_Mousedown(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
If e.Button = MouseButtons.Left Then
MsgBox(" You clicked the Left mousebutton")
End If
End Sub

yes thank you but i want to explain my situation:
i have a custom control that merge 2 controls which i play with the visibility ,so i want to handle the mouse click not in the form because the custom control it's like a form so i need the mouse click outside this "form".
thank you. :)

Private mouse_Click As Integer = 0 '// keep track of clicks.

    Private Sub Button1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
        Handles Button1.MouseClick, Button2.MouseClick, ListBox1.MouseClick, TextBox1.MouseClick, TextBox2.MouseClick, _
         TextBox3.MouseClick
        mouse_Click += 1 '// increase count by 1.
        Me.Text = mouse_Click
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.