|
대충 구현을 해봤습니다.
원하시는 기능이 다 구현되었는지는 모르겠습니다.
참고하세요.. 예외처리 조금만 넣고하면 제대로 돌아갈것 같기도 합니다 ^^;
제코드가 워낙에 신빙성이 없는 코드라 -_-;
int PrevTop; // 전역변수로 선언
void __fastcall TForm1::FormCreate(TObject *Sender)
{
PrevTop = 0;
t = new TCheckBox(this);
//초기 선언 구현부분
StringGrid1->Objects[0][0] = t;
t->Parent = StringGrid1;
t->BoundsRect = StringGrid1->CellRect(0,0);
t->Width = StringGrid1->ColWidths[0];
t->Height = StringGrid1->RowHeights[0];
t->OnMouseUp = CheckBoxMouseUp;
t->Caption = IntToStr(StringGrid1->TopRow); // 글 쓰는 중에 임의 수정
t->Checked = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::CheckBoxMouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
TCheckBox* cbCheck = dynamic_cast<TCheckBox*>(Sender);
cbCheck->Checked = !cbCheck->Checked;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
delete t;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::StringGrid1TopLeftChanged(TObject *Sender)
{
StringGrid1->Repaint();
int CurTop = StringGrid1->TopRow;
StringGrid1->Objects[PrevTop][0] = NULL;
StringGrid1->Objects[CurTop][0] = t;
t->BoundsRect = StringGrid1->CellRect(0,CurTop);
t->Caption = IntToStr(CurTop);
PrevTop = CurTop;
}
//---------------------------------------------------------------------------
|