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

多個StringGrid和一個popupMenu的問題..

答題得分者是:pedro
ychch0819
一般會員


發表:25
回覆:29
積分:15
註冊:2006-08-09

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-05-29 15:37:53 IP:59.120.xxx.xxx 訂閱
請問一下 我用pagecontrol切很多tabsheet,每個tabsheet上都放一個StringGrid, 

而每個StringGrid共用一個popupmenu。

問題是當我按下Popupmenu上的某一個menuitems時,我可以抓出來是在哪一個StringGrid上按的嗎,
因為在menuitem click事件中需要知道某一個StringGrid的一些property,
還是只能每一個StringGrid有各自的popupmenu!?,謝謝
pedro
尊榮會員


發表:152
回覆:1187
積分:892
註冊:2002-06-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-05-29 15:59:35 IP:60.248.xxx.xxx 未訂閱
Delphi syntax:
property PopupComponent: TComponent;
C syntax:
__property Classes::TComponent* PopupComponent = {read=FPopupComponent, write=FPopupComponent};
Description
Read PopupComponent to determine which control is currently using the popup menu. In applications where multiple controls share the same pop-up menu, use PopupComponent to determine which of them displayed the menu.
Set PopupComponent to associate a control with the menu before calling the Popup method programmatically to bring up the pop-up menu.
harpist
資深會員


發表:3
回覆:251
積分:430
註冊:2002-10-03

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-05-29 16:23:52 IP:59.105.xxx.xxx 未訂閱
你可以在TStringGrid 的 OnContextPopup 事件裡面紀錄產生的 StringGrid
<textarea class="cpp" rows="10" cols="60" name="code">TStringGrid *OnPopStringGrid; //--------------------------------------------------------------------------- void __fastcall TForm1::StringGrid1ContextPopup(TObject *Sender, TPoint &MousePos, bool &Handled) { OnPopStringGrid = (TStringGrid*)Sender; } //--------------------------------------------------------------------------- void __fastcall TForm1::N1Click(TObject *Sender) { ShowMessage(OnPopStringGrid->Name); } //--------------------------------------------------------------------------- </textarea>
------
~§~迷時師渡,悟了自渡~§~
編輯記錄
harpist 重新編輯於 2007-05-29 16:24:31, 註解 無‧
ychch0819
一般會員


發表:25
回覆:29
積分:15
註冊:2006-08-09

發送簡訊給我
#4 引用回覆 回覆 發表時間:2007-05-29 16:28:07 IP:59.120.xxx.xxx 訂閱
謝謝兩位,兩位的方法都可行,但因第一位比較方便,就選他了,謝謝
系統時間:2024-05-06 13:52:44
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!