473,795 Members | 3,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1585
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.Draw String(...)
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.Reflecti on Master "

==== Converting to 2002 ====
Remove inline declarations
"Merlin" <iM*****@hotmai l.com> wrote in message
news:bl******** **@titan.btinte rnet.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
16321
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
8122
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 mousedown to handle mybase.mousedown but it doesn't detect the mousedown event until I move out of the pictureboxes I have created (only works on the part of the form where I don't have any pictureboxes). I also cannot set the mousedown event to...
4
4743
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 Label1_MouseDown _ (ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles Label1.MouseDown
2
3564
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 because I entered the following Sub Private Sub MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles AxWebBrowser1.MouseDown
2
1255
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
6786
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 textbox names in the drawing procedure. Now what I need to do is to get the control's information on a mouse down. Here is what I have: //// Private Sub tcGuard_MouseDown(ByVal sender as Object, ByVal e as
1
5219
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 pressed while dragging the Form window to resize it. Can this "problem" be explained as some sort of by-design behavior? If so what is the work around to detecting when a user has completed resizing a Windows Form by way of mouse drag? / ...
2
3019
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 textboxes when clicked on, will select all of the text inside of them using the textbox.selectall(). I'm hoping to do this without creating 30 different Subs. How do I do it?
2
2810
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 Studio 2005. 2) A project will be created with one Form (Form 1). Don't add any code to the project. 3) Run the project and confirm that Form 1 is displayed and you can drag the Form around your screen by clicking and dragging the Form's
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.