線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:5140
推到 Plurk!
推到 Facebook!

如何使用StringGrid DrawCell事件中的TGridDrawState State

尚未結案
frederick
中階會員


發表:101
回覆:108
積分:66
註冊:2002-08-01

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-12-22 10:36:18 IP:210.244.xxx.xxx 未訂閱
請問一下:
這是StringGrid的事件
void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
      int ARow, TRect &Rect, TGridDrawState State)
關於TGridDrawState State,如何以BCB引用呢? 之前是看站上文章,delphi的語法:if (state = [gdSelected]) then 我有試過state == gdSelected,但好像不行。 不知要用何種方法。 發表人 - frederick 於 2003/12/22 15:25:30 發表人 - taishyang 於 2003/12/22 18:46:29
jason_cyl329
高階會員


發表:123
回覆:155
積分:105
註冊:2003-05-26

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-12-23 18:39:37 IP:61.218.xxx.xxx 未訂閱
1.你要將DefaultDrawing設為true
frederick
中階會員


發表:101
回覆:108
積分:66
註冊:2002-08-01

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-12-23 21:10:39 IP:203.70.xxx.xxx 未訂閱
引言: 1.你要將DefaultDrawing設為true
jason_cyl329您好: 感謝您的回復, 不過我試過,應不是這屬性上的問題耶~
RaynorPao
版主


發表:139
回覆:3622
積分:7025
註冊:2002-08-12

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-12-23 21:54:53 IP:61.221.xxx.xxx 未訂閱
引言: 請問一下:
這是StringGrid的事件
void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
      int ARow, TRect &Rect, TGridDrawState State) {
    if (  State == gdFocused )  {
     StringGrid1->Canvas->Brush->Color = clGreen;
      StringGrid1->Canvas->FillRect(Rect);
      StringGrid1->Canvas->TextRect(Rect, Rect.Left + 2, Rect.Top + 2, StringGrid1->Cells[ACol][ARow]);
   }
}
關於TGridDrawState State,如何以BCB引用呢? 之前是看站上文章,delphi的語法:if (state = [gdSelected]) then 我有試過state == gdSelected,但好像不行。 不知要用何種方法。
frederick 你好: 試試看這樣子寫行不行呢?? < class="code"> void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol, int ARow, TRect &Rect, TGridDrawState State) { if(ARow>0 && ACol>0) { if(State.Contains(gdSelected)) { StringGrid1->Canvas->Brush->Color=clGreen; StringGrid1->Canvas->FillRect(Rect); StringGrid1->Canvas->TextRect(Rect, Rect.Left+2, Rect.Top+2, StringGrid1->Cells[ACol][ARow]); } } } -- Enjoy Researching & Developing --
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
frederick
中階會員


發表:101
回覆:108
積分:66
註冊:2002-08-01

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-12-23 23:49:09 IP:210.244.xxx.xxx 未訂閱
哇~真是太神奇了,與HELP對照後,可以了耶~ 謝謝包子哥。    此原文是參考: 【Delphi】【問題】有辦法改變StringGrid的光棒的顏色嗎  http://delphi.ktop.com.tw/topic.php?TOPIC_ID=42421 發表人 - frederick 於 2003/12/23 23:53:56
系統時間:2024-05-08 5:13:48
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!