By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,573 Members | 1,939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,573 IT Pros & Developers. It's quick & easy.

MouseDown Handler

P: n/a
I have created a UserControl which has a label; what I wish to do is place
this UserControl on a form and then trap the Mouse Down event, whenever
someone clicks my control. My problem is that the Mouse Down event for the
UserControl is not detected if the mouse cursor is placed over the label
inside the control, i.e the label within the control has trapped the event
so I don't get to see it.

I've looked at adding the label mousedown handle event to the controls
mousedown, but that doesn't work either; I can get around this easy enough
by making my own event handler - but just wondered if there were another
way.

Thanks,
Merlin
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Instead of using the label, you could draw the text in the Paint event of
your usercontrol, i.e.

Public Sub OnPaintControl(ByVal sender As Object, ByVal e As PaintEventArgs)
Handles MyBase.Paint
e.Graphics.DrawString(...)
End Sub

If the text of the label changed, then call Me.Invalidate to redraw the
text.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"Merlin" <iM*****@hotmail.com> wrote in message
news:bl**********@titan.btinternet.com...
I have created a UserControl which has a label; what I wish to do is place
this UserControl on a form and then trap the Mouse Down event, whenever
someone clicks my control. My problem is that the Mouse Down event for the
UserControl is not detected if the mouse cursor is placed over the label
inside the control, i.e the label within the control has trapped the event
so I don't get to see it.

I've looked at adding the label mousedown handle event to the controls
mousedown, but that doesn't work either; I can get around this easy enough
by making my own event handler - but just wondered if there were another
way.

Thanks,
Merlin

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.