473,414 Members | 1,823 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,414 software developers and data experts.

Ignoring mouse event from contained controls

Hello!

I have a UserControl that have two other controls inside it. I need to set a
different border color for my UserControl when the mouse enters it, and
restore the border color when the mouse leaves it.

The problem is, when the mouse passes in a contained control, the
UserControl raises a MouseLeave and the border is restored back, although
the mouse, for the customer, is yet inside the UserControl.

It's possible I do the UserControl ignores all mouse events for his
contained controls? Or there is another approach?

Cesar
May 8 '06 #1
4 1986
Add the child control to your handles as well.

For instance if you have a panel named Panel1 with a label named Label1
contained in it you can use:
Private Sub Panel1_MouseEnter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Panel1.MouseEnter, _

Label1.MouseEnter

Panel1.BackColor = Color.Black

End Sub
Then do the same thing for the mouseleave event
"ronchese" <info(a)carsoftnet.com.br> wrote in message
news:e5**************@TK2MSFTNGP02.phx.gbl...
Hello!

I have a UserControl that have two other controls inside it. I need to set
a different border color for my UserControl when the mouse enters it, and
restore the border color when the mouse leaves it.

The problem is, when the mouse passes in a contained control, the
UserControl raises a MouseLeave and the border is restored back, although
the mouse, for the customer, is yet inside the UserControl.

It's possible I do the UserControl ignores all mouse events for his
contained controls? Or there is another approach?

Cesar

May 8 '06 #2
Yeah, I did that already.

But that makes me paint the control everytime a contained control get the
focus, once the control is already painted with that status, because the
mouse is already inside it.

I was trying to get a way to ensure that border is painted just one time per
MouseEnter and just one time per MouseLeave. It can be performatic when
eventually I start painting hard drawings on there.

But thanks anyways, for the response.

Cesar


"Jason" <js******@comcast.net> wrote in message
news:G9********************@comcast.com...
Add the child control to your handles as well.

For instance if you have a panel named Panel1 with a label named Label1
contained in it you can use:
Private Sub Panel1_MouseEnter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Panel1.MouseEnter, _
Label1.MouseEnter

Panel1.BackColor = Color.Black

End Sub
Then do the same thing for the mouseleave event
"ronchese" <info(a)carsoftnet.com.br> wrote in message
news:e5**************@TK2MSFTNGP02.phx.gbl...
Hello!

I have a UserControl that have two other controls inside it. I need to
set a different border color for my UserControl when the mouse enters it,
and restore the border color when the mouse leaves it.

The problem is, when the mouse passes in a contained control, the
UserControl raises a MouseLeave and the border is restored back, although
the mouse, for the customer, is yet inside the UserControl.

It's possible I do the UserControl ignores all mouse events for his
contained controls? Or there is another approach?

Cesar


May 8 '06 #3
What kind of controls are they? Can you set the enabled property of the
child controls to False? If so, this should keep it from triggering event.

"ronchese" <info(a)carsoftnet.com.br> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Yeah, I did that already.

But that makes me paint the control everytime a contained control get the
focus, once the control is already painted with that status, because the
mouse is already inside it.

I was trying to get a way to ensure that border is painted just one time
per MouseEnter and just one time per MouseLeave. It can be performatic
when eventually I start painting hard drawings on there.

But thanks anyways, for the response.

Cesar


"Jason" <js******@comcast.net> wrote in message
news:G9********************@comcast.com...
Add the child control to your handles as well.

For instance if you have a panel named Panel1 with a label named Label1
contained in it you can use:
Private Sub Panel1_MouseEnter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Panel1.MouseEnter, _
Label1.MouseEnter

Panel1.BackColor = Color.Black

End Sub
Then do the same thing for the mouseleave event
"ronchese" <info(a)carsoftnet.com.br> wrote in message
news:e5**************@TK2MSFTNGP02.phx.gbl...
Hello!

I have a UserControl that have two other controls inside it. I need to
set a different border color for my UserControl when the mouse enters
it, and restore the border color when the mouse leaves it.

The problem is, when the mouse passes in a contained control, the
UserControl raises a MouseLeave and the border is restored back,
although the mouse, for the customer, is yet inside the UserControl.

It's possible I do the UserControl ignores all mouse events for his
contained controls? Or there is another approach?

Cesar



May 8 '06 #4
I use some labels. On disabling it, is turning the texts disabled, too.
"Jason" <js******@comcast.net> wrote in message
news:QJ********************@comcast.com...
What kind of controls are they? Can you set the enabled property of the
child controls to False? If so, this should keep it from triggering
event.

"ronchese" <info(a)carsoftnet.com.br> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Yeah, I did that already.

But that makes me paint the control everytime a contained control get the
focus, once the control is already painted with that status, because the
mouse is already inside it.

I was trying to get a way to ensure that border is painted just one time
per MouseEnter and just one time per MouseLeave. It can be performatic
when eventually I start painting hard drawings on there.

But thanks anyways, for the response.

Cesar


"Jason" <js******@comcast.net> wrote in message
news:G9********************@comcast.com...
Add the child control to your handles as well.

For instance if you have a panel named Panel1 with a label named Label1
contained in it you can use:
Private Sub Panel1_MouseEnter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Panel1.MouseEnter, _
Label1.MouseEnter

Panel1.BackColor = Color.Black

End Sub
Then do the same thing for the mouseleave event
"ronchese" <info(a)carsoftnet.com.br> wrote in message
news:e5**************@TK2MSFTNGP02.phx.gbl...
Hello!

I have a UserControl that have two other controls inside it. I need to
set a different border color for my UserControl when the mouse enters
it, and restore the border color when the mouse leaves it.

The problem is, when the mouse passes in a contained control, the
UserControl raises a MouseLeave and the border is restored back,
although the mouse, for the customer, is yet inside the UserControl.

It's possible I do the UserControl ignores all mouse events for his
contained controls? Or there is another approach?

Cesar



May 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: red | last post by:
mouse events when the mouse is on a "child control" hi everyone; my problem: I have a userControl in this usercontrol, I have a child control (a button) when the mouse moves over the...
5
by: Mike | last post by:
Currently, when my application needs to write/read to a database, there is a time lag. In that time lag, a user can click the same button multiple times causing my app problems. I want to turn...
2
by: Anders Eriksson | last post by:
Hello! I have a program with three views ------------------------------------ | | | | 1 | 2 | | | ...
2
by: KarenP | last post by:
In my Windows Forms application, while executing a process that takes some time, I am changing the cursor to the hourglass by setting Cursor.Current = Cursors.WaitCursor. This is working just...
3
by: Lance | last post by:
I've noticed that controls that are contained in MDI child forms fail to raise MouseLeave events if the MDI child form's MdiParent property is set to Nothing (after it was set to an existing MDI...
7
by: RobKinney1 | last post by:
The subject line sounds a little funny, let me quickly explain: I have created a custom control using ComboBox. But inside my class, I need to know when the user does NOT click my control. Of...
6
by: Rob | last post by:
This is a curious problem. It seems like it should be quite easy. Of course a timer is used to determine when form should be closed, but how do you consistently reset the timer when the mouse is...
2
by: cefrancke | last post by:
Is there a way to capture all relevant info about the mouse, without using Mouse Up/Down etc. procedures? I'm trying to make a custom function and send it the mouse info on the click event. ...
5
by: moonie | last post by:
I have an msn style c# windows application with a form and panel on it. A news list is drawn from the database and dynamically added via labels, link lables during form loading. In this...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.