-1
應用我有()從按鈕派生的按鈕類
與位置屬性
F#windowsforms與自定義類
namespace fgame15
open System
open System.Windows.Forms
open System.Drawing
module Game15Button =
type Game15Button(position:Point) as button =
inherit Button()
member this.Pozition = position
這是顯示一種形式
它沒有任何錯誤的編譯我的主要模塊,但
不顯示形式按鈕
namespace fgame15
open System
open System.Drawing
open System.Windows.Forms
module Main =
do
let form = new Form(BackColor = Color.Pink , Text = "My Window Application")
let btn=new Button()
btn.Text <- "Ok"
form.Controls.Add(btn)
Application.Run(form)
打印以下警告
Warning 1 Main module of program is empty: nothing will happen when it is run
你的第二個例子工作得很好。 – vcsjones
是的,第二個例子工作正常,但是當我添加按鈕類時,它不起作用 –
您可能需要使用按鈕類移動文件,以使其顯示在主模塊之前(文件順序在F#中很重要) –