17

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.

Adam Haile
  • 30,705
  • 58
  • 191
  • 286

3 Answers3

15

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#

Ricardo Amores
  • 4,597
  • 1
  • 31
  • 45
11

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.

Mikayla Hutchinson
  • 16,113
  • 2
  • 44
  • 50
  • 1
    We are using the System.Windows.Forms namespace as we already have our UIs built. For additional work in the UI we are using SharpDevelop, and then coding in MD. – IAbstract Feb 22 '10 at 03:38
7

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.

alexchandel
  • 532
  • 6
  • 15