System.Windows.Forms.Control.Invalidate C# (CSharp) Method

Invalidate() public method

public Invalidate ( Rectangle rc, bool invalidateChildren ) : void
rc System.Drawing.Rectangle
invalidateChildren bool
return void
		public void Invalidate (Rectangle rc, bool invalidateChildren)
		{
			// Win32 invalidates control including when Width and Height is equal 0
			// or is not visible, only Paint event must be care about this.
			if (!IsHandleCreated)
				return;
			
			if (rc.IsEmpty)
				rc = ClientRectangle;
			
			if (rc.Width > 0 && rc.Height > 0)
			{
				
				NotifyInvalidate (rc);
				
				NSViewForControl.SetNeedsDisplayInRect (rc);
				
				if (invalidateChildren)
				{
					Control[] controls = child_controls.GetAllControls ();
					for (int i = 0; i < controls.Length; i++)
						controls[i].Invalidate ();
				}

				else
				{
					// If any of our children are transparent, we
					// have to invalidate them anyways
					foreach (Control c in Controls)
						if (c.BackColor.A != 255)
							c.Invalidate ();
				}
			}
			OnInvalidated (new InvalidateEventArgs (rc));
		}
		

Same methods

Control::Invalidate ( ) : void
Control::Invalidate ( Rectangle rc ) : void
Control::Invalidate ( Region region ) : void
Control::Invalidate ( Region region, bool invalidateChildren ) : void
Control::Invalidate ( bool invalidateChildren ) : void

Usage Example

Example #1
0
		public CloseBox(Control host)
		{
			this.host = host;

			host.Resize += delegate { host.Invalidate(); };

			host.MouseLeave += delegate
			{
				hover = false;
				host.Invalidate();
			};

			host.MouseMove += delegate(object sender, MouseEventArgs e)
			{
				bool h = bounds.Contains(e.Location);
				
				if (hover != h)
				{
					hover = h;
					host.Invalidate();
				}
			};

			host.MouseUp += delegate(object sender, MouseEventArgs e)
			{
				if (bounds.Contains(e.Location) && e.Button == MouseButtons.Left)
					Clicked();
			};
		}
All Usage Examples Of System.Windows.Forms.Control::Invalidate
Control