MonoDevelop中的WinForms应用程序

Ada*_*ile 17 mono monodevelop winforms

我刚安装了新的MonoDevelop Windows测试版,但在尝试创建C#windows应用程序时,唯一的选择是GTK#.由于Mono支持WinForms,为什么这不是MonoDevelop的选项.我想在我的应用程序中没有GTK#依赖项.

Ric*_*res 13

虽然从版本2.0开始支持单声道Winforms,WinForms设计器在MonoDevelop中尚未使用,这可能是MonoDevelop中缺少WinForms项目的原因

http://www.mono-project.com/WinForms_Designer

AFAIK,你应该考虑mono对winforms的支持,将现有的winforms aplication移植到linux.如果你想从头开始制作一个跨平台的应用程序,你应该使用GTK#


Mik*_*son 8

虽然没有WinForms项目模板,但您可以在MD上运行的任何平台上编写WinForms应用程序.

只需创建一个新的空C#项目并添加对System.Windows.Forms的引用,然后编写代码,然后构建并运行.尽管MD中没有Winforms设计器,但您将获得Winforms类型的代码完成.


ale*_*del 6

很抱歉让死人复活,但我最近试图这样做.虽然MonoDevelop不提供GUI设计器,但您确实可以手动编写Winforms,正如mhutch指出的那样.它是这样的:

  • 创建一个新的空C#项目.
  • 添加对System.Windows.Forms的引用
  • 创建一个新的空C#文件:

文件内容:

using System;
using System.Windows.Forms;

namespace HelloForms
{
    public class MainForm: Form
    {
        Label label1 = new Label();

        public MainForm ()
        {
            this.SuspendLayout();

            // Initialize your components here
            this.label1.Text = "Hello, World!";

            this.Controls.Add(label1);
            this.ResumeLayout();
            this.Name = "MainForm Name.";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "MainForm Title!";

        }
    }

    public class Program
    {
        public static void Main(string[] args) {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm ());
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

通过向MainForm的构造函数添加组件来扩展您的表单.