void __fastcall TForm1::Button1Click(TObject *Sender)
{
int lineCount,fontH;
lineCount=Memo1->Lines->Count;
//fontSize=Memo1->Font->Size;//Size:Specifies the height of the font in points.
fontH=Memo1->Font->Height;//Height:Use Height to specify the height of the font in pixels.
Memo1->Height=-lineCount*fontH; //Height:Specifies the vertical size of the control in pixels.
}