Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / WinForms

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

1.00/5 (1 vote)
10 Aug 2011CPOL 11.6K  
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)