|
방태윤 님이 쓰신 글 :
: 저는 DrawText 를 사용합니다...
: DrawText(StringGrid1->Canvas->Handle,
: StringGrid1->Cells[ACol][ARow].c_str(),-1,&Rect,DT_SINGLELINE|DT_VCENTER|DT_CENTER);
:
:
:
: 앙마 님이 쓰신 글 :
: : StringGrid는 정렬기능이 없어서 자체적으로 DrawCell에 뿌려줘야 하는데 ..아래코드는 가운데 정렬이자나염..그런데..가운데 정렬을 했는데..글자는 좌우를 기준으로 해서 가운데로 잘모이는데욤..셀의 상하는 안맞춰지던데...셀의 가운데에서 위쪽으로 몰리는데..이건 어떻게 해결하는지 궁금하네요.. 따로 세로크기를 지정해서 그것도 가운데 정렬을 한번더 해줘야 하는지?? Excell처럼 말이죠..
: :
: : void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
: : int ARow, TRect &Rect, TGridDrawState State)
: : {
: : unsigned oldalign = SetTextAlign(StringGrid1->Canvas->Handle, TA_CENTER);
: : StringGrid1->Canvas->TextRect(Rect, (Rect.Right+Rect.Left)/2, Rect.Top+2,
: : StringGrid1->Cells[ACol][ARow]);
: : SetTextAlign(StringGrid1->Canvas->Handle, oldalign);
: : }
: :
그냥 DrawCell에다가 뿌렸는데염..
void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
int TextHeight;
TextHeight = StringGrid1->Canvas->TextHeight(StringGrid1->Cells[ACol][ARow]);
unsigned oldalign = SetTextAlign(StringGrid1->Canvas->Handle, TA_CENTER); //Center정렬
StringGrid1->Canvas->TextRect( Rect
, (Rect.left + Rect.right)/2
, Rect.top + (Rect.Height()/2 - TextHeight/2)
, StringGrid1->Cells[ACol][ARow]);
SetTextAlign(StringGrid1->Canvas->Handle, oldalign);
unsigned oldalign = SetTextAlign(StringGrid1->Canvas->Handle, TA_RIGHT); //Right정렬
StringGrid1->Canvas->TextRect( Rect
, Rect.Right - 10
, Rect.top + (Rect.Height()/2 - TextHeight/2)
, StringGrid1->Cells[ACol][ARow]);
SetTextAlign(StringGrid1->Canvas->Handle, oldalign);
}
|