2008-12-18 68 views
1

我摆弄的代码是:试图找出如何引爆的事件时按下Enter键在TextBox按下

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

你知道你玩的时候太多晕... 你打电话给你的表格“tehForm”。 – jcollum 2008-12-18 19:37:18

回答

1

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

Here's the MSDN documentation

+0

这回答了我的问题,谢谢! – Rayne 2008-12-18 19:58:00

相关问题