最近 F# を学び始めましたが、WinForms を使用するのはこれが初めてです。これが私のコードです。
#light
open System
open System.Windows.Forms
let form =
let temp = new Form()
let ms = new MenuStrip()
let file = new ToolStripDropDownButton("File")
ignore(ms.Items.Add(file))
ignore(file.DropDownItems.Add("TestItem")) \\Code of importance
let things _ _ = ignore(MessageBox.Show("Hai"))
let handle = new EventHandler(things)
ignore(file.Click.AddHandler(handle))
let stuff _ _ = ignore(MessageBox.Show("Hai thar."))
let handler = new EventHandler(stuff)
let myButton = new Button(Text = "My button :>", Left = 8, Top = 100, Width = 80)
myButton.Click.AddHandler(handler)
let dc c = (c :> Control)
temp.Controls.AddRange([| dc myButton; dc ms |]);
temp
do Application.Run(form)
問題は何ですか。DropDownItems アイテムを使用できるようにハンドルを取得する方法がわかりません。単純なことだと思いますが、F# をそれほど長く使用していません。助けてくれてありがとう。
編集:また、そのコードブロックには多くの醜い構文があることを知っていることも指摘したいと思いますが、全体は私が使用してきた単なるテストフォームです.