0

I Have a TableLayoutpannel which is populated by a Custom Control that I created.

What I need is how to get the mouse position when i right click on a custom control ?

I tried the MouseUp event but when I click on a custom control the event is not raised but it is when I click on an area with no custom control.

So people, how could I retrieve the mouse position when I right click on a custom control which is hold on a TableLayoutpannel?

Thank you.

Blood-HaZaRd
  • 2,049
  • 2
  • 20
  • 43
  • 1
    I am guessing that you mean a UserControl? They get mouse events, but in some cases they might have to be "bubbled up" by other controls there. – Ňɏssa Pøngjǣrdenlarp Dec 21 '14 at 21:29
  • If nothing else, overriding [wndproc](http://stackoverflow.com/questions/19529878/where-to-call-base-wndproc-or-base-defwndproc) always helps. – Victor Zakharov Dec 21 '14 at 21:35
  • @Plutonix It is a user control that created in a seperate project. And in another project i have a TableLayoutPannel containing instances of that controls – Blood-HaZaRd Dec 21 '14 at 22:12
  • @Neolisk : I use VB.net – Blood-HaZaRd Dec 21 '14 at 22:13
  • then some of the things on that user control may be getting the click - the TLP likely has nothing to do with it. The UserControl is only going to report clicks on that starting canvas (the actual user control). If there are buttons and text control and such, THEY are getting the clicks, just like if the whole thing was a Panel with stuff on it – Ňɏssa Pøngjǣrdenlarp Dec 21 '14 at 22:14
  • So what should I do To be able to get mouse pos on my UserControls ? – Blood-HaZaRd Dec 21 '14 at 22:17
  • whats on this thing, what does it do? we have no starting point other than to say "bubble up the event from the child controls". – Ňɏssa Pøngjǣrdenlarp Dec 21 '14 at 22:19
  • And How to bubble up events from the child controls ? Thx – Blood-HaZaRd Dec 21 '14 at 22:21
  • 1
    In the UserControl, make all the controls within fire the same `MouseDown` event by listing them all after the `Handles` clause (or wire them up at run-time with AddHandler). Then make the UserControl raise a `Custom Event` that the Form with the TableLayoutPanel subscribes to. – Idle_Mind Dec 22 '14 at 01:14

1 Answers1

0

Use MouseDown Event

Private Sub Form5_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
    If e.Button = Windows.Forms.MouseButtons.Right Then
        ToolTip1.SetToolTip(Button1, e.Location.ToString)
    End If
End Sub