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

GetPreferredSize() protected method

protected GetPreferredSize ( Graphics graphics, System.Windows.Forms.DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize ) : Size
graphics System.Drawing.Graphics
cellStyle System.Windows.Forms.DataGridViewCellStyle
rowIndex int
constraintSize System.Drawing.Size
return System.Drawing.Size
		protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize)
		{
			object o = FormattedValue;
			
			if (o != null) {
				Size s = DataGridViewCell.MeasureTextSize (graphics, o.ToString (), cellStyle.Font, TextFormatFlags.Default);
				s.Height = Math.Max (s.Height, 20);
				s.Width += 2;
				return s;
			} else
				return new Size (21, 20);
		}