上一篇主題 :: 下一篇主題 |
發表人 |
內容 |
king_wisely
註冊時間: 2008-02-18 文章: 50
第 1 樓
|
發表於: 星期日 六月 19, 2011 11:32 am 文章主題: 如何知道控制權是在那個物件 |
|
|
請問各位同好:
我有一個 Form A 中有物件 Text1~Text10, 及一個command, 當按下Command時會封行另一個Form, 我想請問如何可以作到如果控制權在某個
Text 時, 按下Command執行另一個FORM後控制權可再交回 Text, 謝謝 |
|
回頂端 |
|
 |
ckp6250
註冊時間: 2004-07-30 文章: 1645
第 2 樓
|
發表於: 星期日 六月 19, 2011 3:09 pm 文章主題: |
|
|
ActiveControl
看看這個屬性適用否? |
|
回頂端 |
|
 |
king_wisely
註冊時間: 2008-02-18 文章: 50
第 3 樓
|
發表於: 星期日 六月 19, 2011 7:35 pm 文章主題: |
|
|
不行, 會出現 Activecontrol is not a object |
|
回頂端 |
|
 |
jys
註冊時間: 2004-12-27 文章: 33 來自: 台灣
第 4 樓
|
發表於: 星期一 六月 20, 2011 7:39 am 文章主題: |
|
|
目前可行的方式是加一個 Form 的屬性,在每個Text 的 GotFocus 將 Text 的 Name 記錄在這個屬性中,
例: NowActiveControl , 在 Text1 Gotfocus 中 ThisForm.NowActiveControl = "Text1"
在 Text2 Gotfocus 中 ThisForm.NowActiveControl = "Text2"
...
Do Form 後
cMacro = "ThisForm."+ThisForm.nowactivecontrol
&cMacro..SetFocus() |
|
回頂端 |
|
 |
king_wisely
註冊時間: 2008-02-18 文章: 50
第 5 樓
|
發表於: 星期一 六月 20, 2011 8:44 am 文章主題: |
|
|
感謝jys, 依你的方式可行 |
|
回頂端 |
|
 |
garfield Site Admin

註冊時間: 2003-01-30 文章: 2160
第 6 樓
|
發表於: 星期五 六月 24, 2011 9:27 am 文章主題: |
|
|
如果你要用這種方法, 不要用
ThisForm.NowActiveControl = "Text1"
改用
ThisForm.NowActiveControl = this
要使用時,用下行語法即行
ThisForm.NowActiveControl.SetFocus() _________________ 利用>>搜尋<<的功能會比問的還要快得到答案. |
|
回頂端 |
|
 |
小賴
註冊時間: 2004-12-27 文章: 476
第 7 樓
|
發表於: 星期五 六月 24, 2011 11:53 am 文章主題: |
|
|
Command1.When :
ThisForm.NewActivecontrol = ThisForm.ActiveControl
Command1.Click :
DO FORM Form2
ThisForm.Newactivecontrol.SetFocus |
|
回頂端 |
|
 |
|