Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# menu WinForm Mouse
I want to get the arguments from PaintEvent (OnPaint) in the Leave Event (OnLeave). Any idea how to access/get them.
Posted 11-Sep-12 1:09am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

if you want to do something in paint when leave event fire then
use Invalidate() method and a flag which will tell your paint event now, leave event regarding if-else block should be run or not.
 
boolean flag = false;
 
Leave event ...
{
   flag = true;
   Mycontrol1.Invalidate(); // it will fire paint event of Mycontrol1
}
 
MyControl1 paint event ...
{
     if (flag==true)
     {
        //draw something
        flag = false;
     }
}
 
Happy coding!
Smile | :)
  Permalink  
Comments
Itz.Irshad at 11-Sep-12 6:31am
   
In case of fast movement of mouse, OnPaint Event didn't perform so well.
aarti meswania at 11-Sep-12 6:37am
   
yes but same thing will be happen if you will declare page level paint argument variable and use it in leave event
if it is possible to use default properties like backcolor/font/border of control then it will be easy
Itz.Irshad at 11-Sep-12 6:52am
   
@Aarti: Here, by declaring page level paint argument variable didn't work for me. In fact, it close the whole application.
aarti meswania at 11-Sep-12 7:00am
   
you should go with 'invalidate() & flag' solution
and avoid painting if it's possible then use default properties for look change
or optimize paint event code
bobpowell is good site for paint regarding issues.
i have suggest a way how you can call paint event from leave event now try to optimize paint event that is a solution only if you don't want to use default properties instead of painting
:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 5,130
1 DamithSL 4,237
2 Maciej Los 3,700
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,846


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 11 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100