TImpStringGrid 아주 좋은 콤포입니다.
하지만 옥에 티라면 셀 내용의 세로 위치를 조정할 수 있는 세로 정렬 기능이 없다는 것이죠.
글들이 셀의 위로 붙어서 보기가 좀 난감합니다.
그래서 아래와 같은 방법을 씁니다.
생각보다 간단히 해결 되죠.
void __fastcall TFormMain::StringGrid1DrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
TImpStringGrid *SG1 = StringGrid1;
unsigned oldalign = SetTextAlign(SG1->Canvas->Handle, TA_CENTER);
if (State.Contains(gdSelected))
{
SG1->Canvas->Brush->Color = clNavy;
}
else
{
SG1->Canvas->Pen->Color = clBlack;
if (ARow == 0)
SG1->Canvas->Brush->Color = ACol < 2 ? clBtnFace : clBtnFace;
else
SG1->Canvas->Brush->Color = clWhite;
}
SG1->Canvas->TextRect(Rect, (Rect.Right+Rect.Left)/2, Rect.Top+5, SG1->Cells[ACol][ARow]);
SetTextAlign(SG1->Canvas->Handle, oldalign);
}
코드는 적당히 수정해서 쓰셔야 합니다.
다들 아시는 분들이 많겠지만 혹 처음 쓰시는 분들을 위해...
|