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
[42069] DBGrid 에 DBCheckbox 넣기
최진호 [] 1291 읽음    2005-10-04 05:35
1.bmp 722.8KB 실행후 파일 캡쳐
DB프로그램을 만들고 있는데 이해가 안되는 부분이 있어서 이렇게 물어 봅니다..

DBGrid 위에 DBCheckBox 와 ADOQuery를 하나 놓고 실행 시키는 프로그램 으로

DBGrid에 DBCheck box를 넣는것 입니다..델파이의 소스를 찾아서 일부를 수정했는데... 이상하게 DBCheckBox에 클릭을 하면 색깔이 바로 변하지 않고 두번 클릭해야 변화가 되고 업데이트가 가능하던데 이런 문제는 어떤식으로 처리 해야 되나요!!!!(마우스 오른쪽 버튼을 클릭하고 다시 윈쪽 버튼을 클릭해야 수정이 가능하게 DBnavigator 버튼이 변하게 됩니다.)





#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    ADOQuery1->Close();
    ADOQuery1->SQL->Clear();
    ADOQuery1->SQL->Add("SELECT * FROM Articles");
    ADOQuery1->Open();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
DBCheckBox1->DataSource = DataSource1;
DBCheckBox1->DataField  = "Winner";
DBCheckBox1->Visible    = False;
DBCheckBox1->Color      = DBGrid1->Color;
DBCheckBox1->Caption    = "";
//explained later in the article
DBCheckBox1->ValueChecked = "출고";
DBCheckBox1->ValueUnchecked = "미출고";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DBGrid1DrawColumnCell(TObject *Sender,
      const TRect &Rect, int DataCol, TColumn *Column,
      TGridDrawState State)
{

const bool  ISChecked[]=
      {int(DFCS_BUTTONCHECK), int(DFCS_BUTTONCHECK)||int(DFCS_CHECKED)};
int DrawState;
TRect DrawRect;

if(State.Contains(Grids::gdFocused))
     {
         if (Column->Field->FieldName == DBCheckBox1->DataField) {
                        DBCheckBox1->Left = Rect.Left + DBGrid1->Left + 27;
                        DBCheckBox1->Top = Rect.Top + DBGrid1->Top+2;
                        DBCheckBox1->Width = Rect.Right - Rect.Left;
                        DBCheckBox1->Height = Rect.Bottom - Rect.Top;
                        DBCheckBox1->Visible = true; }
  

      }

else
      {
            if (Column->Field->FieldName == DBCheckBox1->DataField) {
                        DrawRect=Rect;
                        InflateRect( (RECT *)(&DrawRect),-1,-1);
                        DrawState = ISChecked[Column->Field->AsBoolean];
                        DBGrid1->Canvas->FillRect(Rect);
                        DrawFrameControl(DBGrid1->Canvas->Handle, (RECT *)(&DrawRect),
                        DFC_BUTTON, DrawState); }
      }

}
//---------------------------------------------------------------------------
void __fastcall TForm1::DBGrid1ColExit(TObject *Sender)
{
if (DBGrid1->SelectedField->FieldName == DBCheckBox1->DataField)
    DBCheckBox1->Visible = false;
}

+ -

관련 글 리스트
42069 DBGrid 에 DBCheckbox 넣기 최진호 1291 2005/10/04
42086     Re:DBGrid 에 DBCheckbox 넣기 박지훈.임프 2081 2005/10/05
42100         박지훈.임프 님( 답변 정말 감사합니다..^^) 그럼 수고하세요 최진호 1511 2005/10/06
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.