Click here to Skip to main content
12,998,483 members (127,780 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 0:09am

1 solution

Rate this: bad
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!
Itz.Irshad 11-Sep-12 6:31am
In case of fast movement of mouse, OnPaint Event didn't perform so well.
aarti meswania 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 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 11 Sep 2012
Copyright © CodeProject, 1999-2017
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