Question

I just installed the new MonoDevelop Windows beta, but when trying to create a C# windows application the only option was GTK#. Since Mono supports WinForms, why is this not an option in MonoDevelop. I would like to not have the GTK# dependency in my applications.

Was it helpful?

Solution

Althought Winforms is supported in mono since version 2.0, the WinForms designer is not usable yet in MonoDevelop, which could be the reason for the lack of a WinForms project in MonoDevelop

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

AFAIK, you should think of mono's support for winforms as a way to port existing winforms aplication to linux. If you want to make a cross-platform app from the ground up, you should use GTK#

OTHER TIPS

Although there is no WinForms project template, you can write WinForms apps in MD on any of the platforms MD runs on.

Just create a new empty C# project and add a reference to System.Windows.Forms, then write your code, and build & run. Although there's no Winforms designer in MD, you'll have code completion for the Winforms types.

Sorry for raising the dead, but I tried to do this recently. While MonoDevelop doesn't provide the GUI designer, you can indeed write Winforms by hand, as mhutch pointed out. It goes like this:

  • Create a new, empty C# project.
  • Add a reference to System.Windows.Forms
  • Create a new, empty C# file:

The contents of the file:

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 ());
        }
    }
}

Expand your Form by adding components to MainForm's constructor.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top