Hi all,

I'm in my 2nd year of software development (doing C#) and having come from a Java background, and having programmed a few GUI's in C#/Visual Studio's; I was wondering...
Like in Java You can use an IDE to build a GUI, however you can also simply add Frames, textboxes and so on manually(no IDE just plain java programming). But this does not seem to be present in C#. I have looked around the net and all the had is this:http://msdn.microsoft.com/en-us/library/ms752299.aspx
So my question is why in that case can you not write a GUI manually like in Java, or is it simply because their/Microsofts' GUI creator is good enough?

Sorry if it's silly but i'm really stumped.

Edited 4 Years Ago by DavidKroukamp: n/a

You can create your GUI 'by hand' if you so desire. Open one of your GUI projects and take a look at the Form1.Designer.cs file (for example). That's the stuff you'll have to do to create a form and add controls to it. The Program.cs shows how you'd start up the form you've created.

It's just easier to do in the GUI than it is by hand.

Start a new windows forms app.
Open the Form.cs file and add the extra code after the //+++

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        //+++
        private System.Windows.Forms.Button MyBtn;

        public Form1()
        {
            InitializeComponent();
            //+++
            this.MyBtn = new System.Windows.Forms.Button();
            this.MyBtn.Location = new System.Drawing.Point(100, 100);
            this.MyBtn.Name = "MyBtn";
            this.MyBtn.Size = new System.Drawing.Size(75, 23);
            this.MyBtn.TabIndex = 2;
            this.MyBtn.Text = "A button";
            this.MyBtn.UseVisualStyleBackColor = true;
            this.MyBtn.Click += new System.EventHandler(this.MyBtn_Click);
            this.Controls.Add(MyBtn);
        }

        //+++
        private void MyBtn_Click(object sender, EventArgs e)
        {
            MessageBox.Show("My button clicked.");
        }
    }
}

Run and try it out, this is a Button created without using the VS Designer.
As Momerath I prefer the Designer, who does al that coding for me.
It is still important to know what is happening under the hood and if I have a situation where I want 100 buttons I still program this way, putting al this code in a loop to generate my 100 buttons. In such a situation it becomes harder to use the designer and coding is far better.
You can also use pure C# code with WPF, but I think few people do that.

Edited 4 Years Ago by ddanbe: n/a

Hi all,

I'm in my 2nd year of software development (doing C#) and having come from a Java background, and having programmed a few GUI's in C#/Visual Studio's; I was wondering...
Like in Java You can use an IDE to build a GUI, however you can also simply add Frames, textboxes and so on manually(no IDE just plain java programming). But this does not seem to be present in C#. I have looked around the net and all the had is this:http://msdn.microsoft.com/en-us/library/ms752299.aspx
So my question is why in that case can you not write a GUI manually like in Java, or is it simply because their/Microsofts' GUI creator is good enough?

Sorry if it's silly but i'm really stumped.

OOooH now I get it! And that means my friends wrong :D.
thanks all

This question has already been answered. Start a new discussion instead.