473,320 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

MouseDown Handler

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
1 1563
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JJ | last post by:
Hi All, I need to create a MouseDown event for a picture box . Am I doing the following right? pictureBox.MouseDown += new System.WinForms.MouseEventHandler(pictureBox_MouseDown) Then
7
by: Scott Mackay | last post by:
Hi, I'm using visual studio dotnet 2002 programming in vb can anyone tell me how I can handle the mousedown event for pictureboxes I create dynamically at runtime? I've tried setting the...
4
by: rsmith | last post by:
How can I capture the MouseDown event on a Label ? I entered thr following code and got a " cannot handle Event 'MouseDown' because they do not have the same signature." Private Sub...
2
by: Rob | last post by:
How can I fix the following warning warning BC40004: sub 'MouseDown' conflicts with event 'MouseDown' in the base class 'Control' and so should be declared 'Shadows'. This warning appears...
2
by: shachar | last post by:
hi all. in vb6 when the user clicked on the form, in the "MouseDown" Event i had the x,y positions - where the user clicked. how can i do it in vb.net?
7
by: Brad | last post by:
I have several labels and textboxes that are drawn to a tab page based on certain criteria so these labels and textboxes can be drawn at different points on the tab page. I set the label and...
1
by: JDeats | last post by:
It appears the WinForm MouseDown and MouseUp event handlers are not working properly. In the "bare bones" sample application below, Form1_MouseUp gets called even through the mouse button remains...
2
by: lmefford | last post by:
Is there a way to modify all textboxes on a form so that when you click on any of them you process the SelectAll() function. For exaple, let's say I've created a form with 30 textboxes. These...
2
by: Peter | last post by:
Hi I've discovered a bizarre Windows Forms (VB.NET) behavior that is resulting in a Form not being able to be moved. To reproduce this: 1) Create yourself a new Windows Application in Visual...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.