全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1429
推到 Plurk!
推到 Facebook!

stringgird有checkbox可以選嗎

尚未結案
pricejit2
一般會員


發表:53
回覆:18
積分:14
註冊:2005-01-28

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-06-05 18:02:37 IP:220.229.xxx.xxx 未訂閱
stringgrid 的某一欄位中 有很多checkbox直直列下來 可以讓我去勾選第二欄位的資料 stringgrid可以有checkbox可以選嗎 該怎麼寫呢 謝謝各位大大
supman
尊榮會員


發表:29
回覆:770
積分:924
註冊:2002-04-22

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-06-05 19:31:11 IP:203.204.xxx.xxx 未訂閱
您好: 要自己手動作,以下範例給您參考,試過了有問題再問. http://delphi.ktop.com.tw/topic.php?topic_id=4699 http://delphi.ktop.com.tw/topic.php?topic_id=69289 程式是用DBGrid去做,不過原理一樣. 發表人 - supman 於 2005/06/05 19:32:07
odyaho
初階會員


發表:60
回覆:104
積分:42
註冊:2005-02-15

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-06-05 22:57:51 IP:219.81.xxx.xxx 未訂閱
Dear pricejit2: 請參考 http://delphi.ktop.com.tw/topic.php?topic_id=48816 http://delphi.ktop.com.tw/topic.php?topic_id=36136 http://delphi.ktop.com.tw/topic.php?topic_id=60586 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=29502    善用搜尋...
wameng
版主


發表:31
回覆:1336
積分:1188
註冊:2004-09-16

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-06-06 10:27:12 IP:61.222.xxx.xxx 未訂閱
簡單作法。臨時寫的....
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
Var
  Flags : Integer;
begin
  if (ARow>0) and (ACol=2) then
  begin
    StringGrid1.Canvas.FillRect(Rect);
    Inc(Rect.Top,4);
    Dec(Rect.Bottom,4);        Flags := DFCS_BUTTONCHECK;
    if StringGrid1.Cells[ACol,ARow]='1' then Flags := Flags or DFCS_CHECKED;
    DrawFrameControl(StringGrid1.Canvas.Handle,Rect,DFC_BUTTON,Flags );
  end;
end;    procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
  { 若Grid 不允許修改編輯。則可省略此段處理}
  if (ARow>0) and (ACol=2) then
  begin
    StringGrid1.Options := StringGrid1.Options - [goEditing];
    StringGrid1.EditorMode := False;
  end else StringGrid1.Options := StringGrid1.Options   [goEditing];
end;    procedure TForm1.StringGrid1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  With StringGrid1 do
    if (Row>0) and (Col=2) then
    begin
      Cells[Col,Row] := inttostr(ORD(Cells[Col,Row]<>'1'));
    end;
end;
~~~~~~~~~~~ 難得聰明,常常糊塗。 ~~~~~~~~~~~
系統時間:2024-07-03 16:33:40
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!