C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[23778] [라다][꼴.Free]님 도움 감사합니다. StringGrid에 CheckBox를 넣어서 작업 완료했구요. 메로리관리 측
머리돌 [xxxston] 840 읽음    2003-01-21 09:22

CPP file----------------------

//---------------------------------------------------------------------------
void __fastcall TForm1::CheckBoxMouseUp(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
  TCheckBox* cbCheck = dynamic_cast<TCheckBox*>(Sender);
  cbCheck->Checked = !cbCheck->Checked;
  Checked[StrToInt(cbCheck->Caption)-1] = cbCheck->Checked;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
  tmp=StringGrid1->TopRow-1;
  for(int x=0;x<StringGrid1->VisibleRowCount;x++){
    t=new TCheckBox(this);
    StringGrid1->Objects[StringGrid1->TopRow+x][0] = t;
    t->Parent = StringGrid1;
    t->BoundsRect = StringGrid1->CellRect(1,StringGrid1->TopRow + x);
    t->OnMouseUp = CheckBoxMouseUp;
    t->Caption = IntToStr(StringGrid1->TopRow + x);
  }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::StringGrid1TopLeftChanged(TObject *Sender)
{

  tmp=StringGrid1->TopRow-1;
  for(int x=0;x<StringGrid1->VisibleRowCount;x++){
    t=new TCheckBox(this);
    StringGrid1->Objects[StringGrid1->TopRow+x][0] = t;
    t->Parent = StringGrid1;
    t->BoundsRect = StringGrid1->CellRect(1,StringGrid1->TopRow+x);
    t->OnMouseUp = CheckBoxMouseUp;
    t->Caption = IntToStr(StringGrid1->TopRow+x);
    t->Checked=Checked[StrToInt(t->Caption)-1];
  }
}
//---------------------------------------------------------------------------


void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
  delete t;
}
//---------------------------------------------------------------------------

H file------------------------
class TForm1 : public TForm
{
__published:    // IDE-managed Components
  TStringGrid *StringGrid1;
  void __fastcall StringGrid1TopLeftChanged(TObject *Sender);
  void __fastcall CheckBoxMouseUp(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y);
  void __fastcall FormShow(TObject *Sender);
  void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
private:    // User declarations
public:        // User declarations
  int tmp;
  TCheckBox *t;
  bool Checked[100];
  __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------

+ -

관련 글 리스트
23778 [라다][꼴.Free]님 도움 감사합니다. StringGrid에 CheckBox를 넣어서 작업 완료했구요. 메로리관리 측 머리돌 840 2003/01/21
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.