2013-10-30 39 views
-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 
+0

你的第二個例子工作得很好。 – vcsjones

+0

是的,第二個例子工作正常,但是當我添加按鈕類時,它不起作用 –

+3

您可能需要使用按鈕類移動文件,以使其顯示在主模塊之前(文件順序在F#中很重要) –

回答

0

如果這不是您項目中的最後一個文件fs,它將不會在應用程序啓動時執行。您可以使用VS中的Alt + Up/Alt + Down或使用每個文件上的上下文菜單重新排序文件。