0

[VS Community 2017]

On a Form I have a user control. The user control has 1 Label control (and 4 PictureBox controls, which are not involved in this question).

The Label control sits at position 0,0 of the user control, and the user control at position 0,0 of the Form.

In the user control code, I want to locate the mouse pointer on the Label control.

Private Sub cLblTitle_MouseMove(sender As Object, e As MouseEventArgs) _
    Handles Me.MouseMove

    Debug.Print(e.X.ToString & ", " & e.Y.ToString)
End Sub

The Label control may contain left-aligned text. If it does, only the blank area to the right of the displayed text does give feedback via Debug.Print. If I shorten text (in the running app), more area is responding, if I make it longer, less area is responding, if I remove all text, the whole area up to X=0 is responding.

What does cause this behaviour, and how do I get the mouse position also on the label area containing text?

(I added the VS version in case it might be a bug. I gladly provide more details about the UC/Form if needed.)

  • 1
    `Handles Me.MouseMove` - In the context you have described, "Me" would refer to the user control. Presumably, `cLblTitle` is the variable name of the `Label`. If you want info on the label, handle the events of the label. – TnTinMn Jun 14 '17 at 12:19
  • 1
    As a step to debug/verify that, put a border on the label and see if the events are firing when the mouse is even over the label at all – Ňɏssa Pøngjǣrdenlarp Jun 14 '17 at 12:25
  • @TnTinMn, thanks, I've not realized to change the Handles part after changing the source of the MouseMove. However, _Handles cLblTitle.MouseMove_ does just handle the text, not the part after it. –  Jun 14 '17 at 12:32
  • 1
    @Plutonix, thank you. With this hint, it was clear that AutoSize was on :/ With the combination of TnTinMn's comment, this fixed my problem. –  Jun 14 '17 at 12:43
  • @Plutonix, if you bother to turn your comment into an answer, I'd gladly accept the solution. –  Jun 14 '17 at 15:23
  • You can do a self answer - I'd include both parts...@TnTinMn 's comment was more remedial - mine was to help diagnose – Ňɏssa Pøngjǣrdenlarp Jun 14 '17 at 15:28
  • "eventhough you voted me down" -> And how did you arrive at that false assumption? Comments like that make me wonder why I even bother trying to help people. – TnTinMn Jun 14 '17 at 18:28

0 Answers0