감사합니다.
혹시 StringGrid를 drawcell에서 말고 버튼 클릭하면 해당 셀만 색상을 변화하는 방법은 없을까요?
송신영 님이 쓰신 글 :
: 이밴트 함수 인자 중에 Sender로 해당 컴포넌트 포인터를 TObject * 형으로 받을 수 있습니다,
: 이를 dynamic_cast 를 이용하여 사용하시면 현재 선택한 컴포넌트 포인트를 얻을 수 있습니다.
:
: void __fastcall TForm1::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;
:
: cbCheck1[nSelectIndex] ->Checked = !cbCheck1[nSelectIndex]->Checked;
: }
:
:
:
: 쿼드콥터헬기 님이 쓰신 글 :
: : 안녕하세요 초보 빌더 입니다.
: :
: : 현재 테스트 할려고 소스코드를 짜봤는데 박히는 부분이 MouseUp 이벤트 함수에서 현재 선택한 체크박스가 몇번째 박스 인지 알고 싶습니다. 이벤트처리해야되는데 잘모르겠어요
: :
: : 혹시 추가적으로 체크박스를 선택 했을 때 stringgrid 2번째 열에 노란색, 체크박스 해제될때 회색으로 표시 할 수있는 방법이 없을까요?
: :
: : * 별표시 부분 입니다.
: :
: : void __fastcall TForm1::cbCheckMouseUp(TObject *Sender,
: : TMouseButton Button, TShiftState Shift, int X, int Y)
: : {
: : cbCheck1[cbCheck1->tag]->Checked = !cbCheck1[cbCheck1->tag]->Checked; <------------------ *
: : }
: : //---------------------------------------------------------------------------
: :
: : void __fastcall TForm1::ComboBox1Select(TObject *Sender)
: : {
: : for(int i=0; i<StringGridResult->RowCount; i++)
: : {
: : if(cbCheck1[i] != NULL)
: : {
: : delete cbCheck1[i];
: : cbCheck1[i] = NULL;
: : }
: : }
: :
: : if(ComboBox1->ItemIndex == 0)
: : {
: : for(int i=0; i<3; i++)
: : {
: : cbCheck1[i] = new TCheckBox(StringGridResult);
: : StringGridResult->Objects[0][i+1] = cbCheck1[i];
: : cbCheck1[i]->Parent = StringGridResult;
: : cbCheck1[i]->BoundsRect = StringGridResult->CellRect(0,i+1);
: : cbCheck1[i]->Width = StringGridResult->ColWidths[0];
: : cbCheck1[i]->Height = StringGridResult->RowHeights[0];
: : cbCheck1[i]->OnMouseUp = cbCheckMouseUp;
: : cbCheck1[i]->Caption = i+1;
: : cbCheck1[i]->Tag = i+1;
: : cbCheck1[i]->Checked = false;
: : }
: : }
: : else if(ComboBox1->ItemIndex == 1)
: : {
: : for(int i=0; i<2; i++)
: : {
: : cbCheck1[i] = new TCheckBox(StringGridResult);
: : StringGridResult->Objects[0][i+1] = cbCheck1[i];
: : cbCheck1[i]->Parent = StringGridResult;
: : cbCheck1[i]->BoundsRect = StringGridResult->CellRect(0,i+1);
: : cbCheck1[i]->Width = StringGridResult->ColWidths[0];
: : cbCheck1[i]->Height = StringGridResult->RowHeights[0];
: : cbCheck1[i]->OnMouseUp = cbCheckMouseUp;
: : cbCheck1[i]->Caption = i+1;
: : cbCheck1[i]->Tag = i+1;
: : cbCheck1[i]->Checked = false;
: : }
: : }
: : //---------------------------------------------------------------------------
|