我刚刚安装了新的MonoDevelop Windows测试版,但当我试图创建一个C# windows应用程序时,唯一的选择是GTK#。既然Mono支持WinForms,为什么这不是MonoDevelop中的一个选项。我不希望在我的应用程序中有GTK#依赖。
发布于 2009-09-09 22:19:48
尽管Winforms从2.0版开始支持mono,但WinForms设计器在MonoDevelop中还不能使用,这可能是MonoDevelop中缺少WinForms项目的原因
http://www.mono-project.com/WinForms_Designer
AFAIK,您应该将mono对winforms的支持看作是将现有的winforms应用程序移植到linux的一种方式。如果你想从头开始创建一个跨平台的应用程序,你应该使用GTK#
发布于 2009-09-09 22:27:09
虽然没有WinForms项目模板,但您可以在MD运行的任何平台上用MD编写WinForms应用程序。
只需创建一个新的空C#项目并添加对System.Windows.Forms的引用,然后编写代码,构建并运行即可。尽管MD中没有Winforms设计器,但您将拥有Winforms类型的代码完成功能。
发布于 2013-07-09 07:44:25
很抱歉让死人复活,但我最近也试过这么做。虽然MonoDevelop不提供图形用户界面设计器,但正如mhutch所指出的,你确实可以手工编写Winforms。它是这样的:
文件的内容:
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 ());
}
}
}通过向MainForm的构造函数添加组件来扩展窗体。
https://stackoverflow.com/questions/1402120
复制相似问题