我有一个文本框数组,我在运行时创建了20个文本框,如果一个特定的文本框,我需要获得焦点(如果我在键盘上按下downarrow,如何按下特定文本框的键,它可以是第三个文本框)。
You can add an Event-Handler to your KeyDown-Event:
yourTextboxArray[x].KeyDown += new KeyDownEventHandler(yourMethodHere);
The event has two parameters, sender (Object)
and e (KeyDownEventArgs)
. You can use the sender
to determine what Textbox has send the KeyDown.
Textbox txb_sender = sender as Textbox;
if(txb_sender != null)
// do something here with it
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.