|
검색해 보니 예전 글이 있네요~ 참조하셔요~~
김상영 님이 쓰신 글 :
: 스트링그리드에서 셀에 글자수가넘어가면 2줄로 쓰는 방법이 있으면 가르쳐주세요....
안녕하세요. 홍성진 입니다.
스트링그리드에서 2줄이상 쓰려면..OnDrawCell에서 직접 해주셔야 합니다.
OnDrawCell은 셀이 그려질때 발생하는 이벤트 입니다.
예를 들면 다음의 코드와 같습니다.
void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
if(ACol == 2)
{
StringGrid1->Canvas->TextOut(Rect.Left, Rect.Top, "히히");
StringGrid1->Canvas->TextOut(Rect.Left, Rect.Top+15, "히히2");
}
}
이렇게 하면 세번째 컬럼의 한 셀마다 2줄의 텍스트가 출력됩니다.
이건 단지 예고, 이것을 여러가지로 활용해 보세요.
폰트, 배경등도 셀마다 적용할 수 있습니다.
그럼..
//----------------------------------------------------------------------------------------
안재욱 님이 쓰신 글 :
: void __fastcall Tfworkview::SummuryStringGridDrawCell(TObject *Sender,
: int ACol, int ARow, TRect &Rect, TGridDrawState State)
: {
:
: ...
:
: m_sInTime = m_sDataInCell;
: m_sOutTime = m_sDataInCell.SubString(7, 6);
:
: m_sDataInCell = DBTimeToDisplayTime(m_sInTime); // + "00").SubString(1, 5);
:
: top = Rect.Top + 4;
: left = Rect.Left + ((Rect.Right - Rect.Left) - dynamic_cast<TStringGrid*>(Sender)->Canvas->TextWidth(m_sDataInCell)) / 2;
: dynamic_cast<TStringGrid*>(Sender)->Canvas->TextRect(Rect, left, top, m_sDataInCell);
:
: m_sDataInCell = DBTimeToDisplayTime(m_sOutTime);
:
: top = Rect.Top + 30;
: left = Rect.Left + ((Rect.Right - Rect.Left) - dynamic_cast<TStringGrid*>(Sender)->Canvas->TextWidth(m_sDataInCell)) / 2;
: dynamic_cast<TStringGrid*>(Sender)->Canvas->TextRect(Rect, left, top, m_sDataInCell);
:
: ...
:
: }
:
:
: 요렇게 했는데 마지막 텍스트만 보여줍니다.
: 어떻게 해야하나요?
: 수고하세요.
|