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

StringGrid 的顏色

答題得分者是:physics
yhk
一般會員


發表:11
回覆:7
積分:3
註冊:2002-10-29

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-11-19 18:13:06 IP:61.220.xxx.xxx 未訂閱
請問大家    我在學用 StringGrid, 想說奇數行和偶數行的顏色可以不一樣... strGrid->Cells[0][1] 設置是單一個 CELL...    不知道要怎麼設定?    請問大家知道嗎?
brook
資深會員


發表:57
回覆:323
積分:371
註冊:2002-07-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-11-19 19:47:09 IP:61.222.xxx.xxx 未訂閱
在StringGrid的events的OnDrawCell裡, 1.更改Canvas的字型顏色 2.再用TextOut,把內容再顯示一遍
physics
一般會員


發表:11
回覆:11
積分:9
註冊:2002-05-21

發送簡訊給我
#3 引用回覆 回覆 發表時間:2002-11-20 12:51:52 IP:68.38.xxx.xxx 未訂閱
試試看這樣: void __fastcall TfrmMain::grd1DrawCell(TObject *Sender, int ACol, int ARow, TRect &Rect, TGridDrawState State) { int x = ACol * (grd1->DefaultColWidth 1) 2; int y = ARow * (grd1->DefaultRowHeight 1) 2; Rect.Left = x - 2; Rect.Top = y - 2; Rect.Right = x grd1->DefaultColWidth - 2; Rect.Bottom = y grd1->DefaultRowHeight - 2; if ((float)ACol/2.0 == ACol/2) { grd1->Canvas->Font->Color = clRed; grd1->Canvas->Brush->Color = (TColor)0x00ECECFF; } else { grd1->Canvas->Font->Color = clBlue; grd1->Canvas->Brush->Color = (TColor)0x00FFFFDF; } grd1->Canvas->FillRect(Rect); grd1->Canvas->TextOutA(x, y, IntToStr(x) "," IntToStr(y)); }
yhk
一般會員


發表:11
回覆:7
積分:3
註冊:2002-10-29

發送簡訊給我
#4 引用回覆 回覆 發表時間:2002-11-20 15:51:41 IP:61.220.xxx.xxx 未訂閱
thank you! rook and physics  我發現如果我用 一個 >>
系統時間:2024-04-20 18:02:31
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!