1

我正在玩的代码是:

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(handler) 但这也不起作用。谢谢您的帮助!

4

1 回答 1

1

当 TextBox 获得焦点时触发 OnEnter。使用 OnKeyDown 事件并检查事件参数的 Keys 属性。

这是 MSDN 文档

于 2008-12-18T19:35:03.840 回答