This is my example ,try it please!
----------------------------------------------------------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
private void ChangeBounds()
{
int intLineNum = this.textBox1.Lines.GetLength(0);//The line number of the textbox
float fFontHeight = this.textBox1.Font.GetHeight();//The height of the currently used font in pixel
int intBorderHeight = 0;//The height of the currently used border style
Font font = this.textBox1.Font;
int ifontEmSize = font.FontFamily.GetEmHeight(font.Style);//The EmHeight of the font
int ifontDescent = font.FontFamily.GetCellDescent(font.Style);//Descent height of the font
int ifontAscent = font.FontFamily.GetCellAscent(font.Style);//Ascent height of the font
int ilineSpace = font.FontFamily.GetLineSpacing(font.Style);//Line distence of the font
double dCurRate = fFontHeight / (double) ilineSpace;//The ratio of pixel/DesignUnits
int iLineSpaceHeight = ilineSpace - ifontDescent - ifontAscent;//The height of external leading
switch(this.textBox1.BorderStyle)
// Set the Curently used border height
{
case System.Windows.Forms.BorderStyle.None:
intBorderHeight = 0;
break;
case System.Windows.Forms.BorderStyle.FixedSingle:
intBorderHeight = System.Windows.Forms.SystemInformation.BorderSize.Height;
break;
case System.Windows.Forms.BorderStyle.Fixed3D:
intBorderHeight = System.Windows.Forms.SystemInformation.Border3DSize.Height;
break;
}
if (intLineNum == 0)
//To make the minimised height to the height of one line
{
intLineNum = 1;
}
//Please refer to the following msdn topic
//----http://msdn.microsoft.com/library/en-us/cpguide/html/_gdiplus_obtaining_font_metrics_usecsharp.asp
double d = (double) (intLineNum * ifontEmSize + iLineSpaceHeight) * dCurRate;
int t = (int) ( d + 0.5 ) + 2 * intBorderHeight;
this.textBox1.Height = t;