using System . Runtime . InteropServices;
[ DllImport ( "User32.dll" )]
static extern int SendMessage( IntPtr hWnd, uint Msg, int wParam, int lParam);
private const int EM_GETLINECOUNT = 0x00BA ;
private void textBox1_TextChanged( object sender , EventArgs e)
{
int vCount = SendMessage(textBox1 . Handle, EM_GETLINECOUNT, 0 , 0 );
textBox1 . Height = (textBox1 . Font . Height - 2 ) * vCount + 8 ;
}