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

GetPreferredSize() private method

private GetPreferredSize ( Size proposedSize ) : Size
proposedSize System.Drawing.Size
return System.Drawing.Size
		public virtual Size GetPreferredSize (Size proposedSize) {
			Size retsize = GetPreferredSizeCore (proposedSize);
			
			// If we're bigger than the MaximumSize, fix that
			if (this.maximum_size.Width != 0 && retsize.Width > this.maximum_size.Width)
				retsize.Width = this.maximum_size.Width;
			if (this.maximum_size.Height != 0 && retsize.Height > this.maximum_size.Height)
				retsize.Height = this.maximum_size.Height;
				
			// If we're smaller than the MinimumSize, fix that
			if (this.minimum_size.Width != 0 && retsize.Width < this.minimum_size.Width)
				retsize.Width = this.minimum_size.Width;
			if (this.minimum_size.Height != 0 && retsize.Height < this.minimum_size.Height)
				retsize.Height = this.minimum_size.Height;
				
			return retsize;
		}

Usage Example

Example #1
0
 /// <include file='doc\ToolStripControlHost.uex' path='docs/doc[@for="ToolStripControlHost.GetPreferredSize"]/*' />
 public override Size GetPreferredSize(Size constrainingSize)
 {
     if (control != null)
     {
         return(Control.GetPreferredSize(constrainingSize - Padding.Size) + Padding.Size);
     }
     return(base.GetPreferredSize(constrainingSize));
 }
All Usage Examples Of System.Windows.Forms.Control::GetPreferredSize
Control