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

OnEnter は、TextBox がフォーカスを取得すると発生します。OnKeyDown イベントを使用して、イベント引数の Keys プロパティを確認します。

MSDN のドキュメントは次のとおりです。

于 2008-12-18T19:35:03.840 に答える