Click here to Skip to main content
15,888,454 members
Articles / Desktop Programming / Windows Forms
Tip/Trick

rePaint in OnPaint - How to Clear graphics which has been painted before ( to effect new changes)

Rate me:
Please Sign up or sign in to vote.
1.00/5 (1 vote)
10 Aug 2011CPOL 11.3K   2   1
clear graphis onpaint
if you need to clear the clear the graphics which has been painted before use this tip:
if you need to call OnPaint function when you change a property of class
you can call Invalidate function
and Refresh it !
C#
[Category("Image"),
         Description("Image for the Control" )]
        public Image Images
        {
            get { return _image; }
            set 
            { 
                _image = value; 
                if (this.Parent != null) 
                    Parent.Invalidate(this.Bounds, true);
                this.Refresh();
            }
        }

License

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


Written By
Software Developer (Senior)
Iran (Islamic Republic of) Iran (Islamic Republic of)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralReason for my vote of 1 trivial (everyone painting controls ... Pin
johannesnestler11-Aug-11 3:14
johannesnestler11-Aug-11 3:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.