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

GetContentBounds() protected method

protected GetContentBounds ( Graphics graphics, System.Windows.Forms.DataGridViewCellStyle cellStyle, int rowIndex ) : Rectangle
graphics System.Drawing.Graphics
cellStyle System.Windows.Forms.DataGridViewCellStyle
rowIndex int
return System.Drawing.Rectangle
		protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex)
		{
			if (DataGridView == null)
				return Rectangle.Empty;
				
			object o = FormattedValue;
			Size s = Size.Empty;
			
			if (o != null) {
				s = DataGridViewCell.MeasureTextSize (graphics, o.ToString (), cellStyle.Font, TextFormatFlags.Default);
				s.Height += 2;
			}
			
			return new Rectangle (0, (OwningRow.Height - s.Height) / 2, s.Width, s.Height);
		}