The code I’m playing with is:
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 |])
I thought, by looking at the library, I could use awe.OnEnter.AddHandler(handler) but that didn’t work either. Thanks for the help!
OnEnter fires when the TextBox gets focus. Use the OnKeyDown event and check the Keys property of the event args.
Here’s the MSDN documentation.