Click here to Skip to main content
15,895,799 members

Create a control which will be re-painted only a specified Region not all the Region whenever Paint event is raised?

supernorb asked:

Open original thread
By default, whenever a control is repainted, all its client area / region will be repainted like as using Invalidate() not Invalidate(Region).

If I call Invalidate() myself to repaint the control, it will be OK (I will pass in a specified Region to make it invalidated only). However the control may be invalidated by some code that I can't control (this will invalidate all the control and I don't want this to happen, just some Region is in need to be invalidated).

I've tried overriding OnInvalidated method, but its argument (InvalidateEventArgs) has only a property called InvalidRect (type of Rectangle, not a Region). We all know that calling to Invalidate() will raise the Paint event of the control (for the whole control), calling to Invalidate(Region) will raise the Panit event of the control (for a specified Region on the control), and so I wonder how Invalidate(Region) tells the underlying Paint event raising mechanism to know the Region being painted???

Or there is something special here (compared to almost other events such as MouseUp, MouseDown, MouseMove, KeyPress,...)?

Please help me solve this problem, or tell me if that's impossible. At least I want to know the answer to the question in bold above. Of course, knowing the answer to that question will help me create the control I want. (as mentioned in the title).

Your help would be highly appreciated! Thanks!

VipHaLong
Tags: C#, Windows Forms

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900