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

動態生成StringGrid,使用OnDrawCell事件?

答題得分者是:李國維
deanmac85
一般會員


發表:13
回覆:4
積分:3
註冊:2007-05-29

發送簡訊給我
#1 引用回覆 回覆 發表時間:2010-05-25 13:52:05 IP:122.147.xxx.xxx 未訂閱
動態生成StringGrid,使用OnDrawCell事件?

為什麼compiler會有錯誤,該如何修改,這個事件不能這樣用嗎?
還是有其他方式?

[code cpp]
public: // User declarations
__fastcall TForm1(TComponent* Owner);
TStringGrid *pSetSG ;
void __fastcall SGDrawCell(TObject *Sender, int ACol,int ARow, TRect &Rect, TGridDrawState State);
[/code]


[code cpp]
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
pSetSG = new TStringGrid(this);

pSetSG->OnDrawCell = &SGDrawCell;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SGDrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
//
}

[/code]



李國維
高階會員


發表:42
回覆:287
積分:235
註冊:2003-02-07

發送簡訊給我
#2 引用回覆 回覆 發表時間:2010-05-25 14:14:59 IP:59.120.xxx.xxx 未訂閱
pSetSG->OnDrawCell = (Grids::TDrawCellEvent)&SGDrawCell;
===================引 用 deanmac85 文 章===================
動態生成StringGrid,使用OnDrawCell事件?

為什麼compiler會有錯誤,該如何修改,這個事件不能這樣用嗎?
還是有其他方式?

[code cpp]
public:// User declarations
__fastcall TForm1(TComponent* Owner);
TStringGrid *pSetSG ;
void __fastcall SGDrawCell(TObject *Sender, int ACol,int ARow, TRect &Rect, TGridDrawState State);
[/code]


[code cpp]
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
pSetSG = new TStringGrid(this);

pSetSG->OnDrawCell = &SGDrawCell;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SGDrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
//
}

[/code]



系統時間:2024-04-26 19:07:34
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!