我正在玩的代码是:
open System
open System.Windows.Forms
open System.Drawing
let tehform = new Form(Text = "STOP!", Width = 200, Height = 200)
let awe = new TextBox(Left = 1, Top = 30, Width = 100)
let stuff _ _ = MessageBox.Show(awe.Text) |> ignore
let handler = new EventHandler(stuff)
let yeah = new Button(Text = "", Left = 20, Top = 60, Width = 80)
yeah.Click.AddHandler(handler)
let ms = new MenuStrip()
let file = new ToolStripDropDownButton("File")
let ddi = file.DropDownItems.Add("Hi")
ddi.Click.AddHandler(handler) |> ignore
ms.Items.Add(file) |> ignore
let dc c = (c :> Control)
tehform.Controls.AddRange([| dc yeah; dc ms; dc awe |])
我想,通过查看库,我可以使用awe.OnEnter.AddHandler(处理程序),但这也不起作用。谢谢你的帮助!
答案 0 :(得分:1)
当TextBox获得焦点时,OnEnter将触发。使用OnKeyDown事件并检查事件参数的Keys属性。