Home All Groups Group Topic Archive Search About

Ignoring mouse event from contained controls

Author
8 May 2006 2:35 PM
ronchese
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

Author
8 May 2006 4:12 PM
Jason
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
Show quoteHide quote
"ronchese" <info(a)carsoftnet.com.br> wrote in message
news:e5G2KxqcGHA.3472@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
>
Author
8 May 2006 5:20 PM
ronchese
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




Show quoteHide quote
"Jason" <jshic***@comcast.net> wrote in message
news:G9GdnYvEIdPR88LZRVn-uQ@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:e5G2KxqcGHA.3472@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
>>
>
>
Author
8 May 2006 7:27 PM
Jason
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.

Show quoteHide quote
"ronchese" <info(a)carsoftnet.com.br> wrote in message
news:%236TG7MscGHA.4932@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" <jshic***@comcast.net> wrote in message
> news:G9GdnYvEIdPR88LZRVn-uQ@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:e5G2KxqcGHA.3472@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
>>>
>>
>>
>
>
Author
10 May 2006 7:59 PM
ronchese
I use some labels. On disabling it, is turning the texts disabled, too.


Show quoteHide quote
"Jason" <jshic***@comcast.net> wrote in message
news:QJednTdk5dqrAcLZRVn-vQ@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:%236TG7MscGHA.4932@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" <jshic***@comcast.net> wrote in message
>> news:G9GdnYvEIdPR88LZRVn-uQ@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:e5G2KxqcGHA.3472@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
>>>>
>>>
>>>
>>
>>
>
>