Grid에 체크박스 추가하는 것 까진 자료참고해서 생성했는데요
Grid의 스크롤을 내려도 체크박스는 제자리에 있네요
혹시 해결방법 아시는분 계신가요??
사진과 작성한 소스 첨부하겠습니다.
void __fastcall TForm_Form1::FormCreate(TObject *Sender)
{
AnsiString sDir;
AnsiString sCh;
int iRowCount;
for(int i = 0;i< 10; i++)
{
sCh = IntToStr(i+1);
AdvStringGrid1->Cells[0][i+1] = sCh;
TCheckBox* t = new TCheckBox(this);
AdvStringGrid1->Objects[0][i] = t;
t->Parent = AdvStringGrid1;
t->BoundsRect = AdvStringGrid1->CellRect(1,i+1);
t->Width = 15;
t->Height = 15;
t->OnMouseUp = cbCheckMouseUp;
}
}
void __fastcall TForm_Form1::cbCheckMouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
TCheckBox * pChkBox = dynamic_cast<TCheckBox *>(Sender);
if(pChkBox == NULL) return;
int nSelectIndex = pChkBox ->Tag;
if(pChkBox ->Checked == 0 ) pChkBox ->Checked = 1;
else pChkBox ->Checked = 0;
}
|