Why am I getting the following compile error:
It's a pretty straight forward gui form. Here is the code I am using?
What's my error?
C#:
error CS1003: Syntax error, ':' expected
It's a pretty straight forward gui form. Here is the code I am using?
C#:
using System;
using System.Windows.Forms;
public class FrmMain
{
TextBox txt1 = new TextBox();
Button btn1 = new Button();
Label lblMsg = new Label();
public FrmMain()
{
Form frmMain = new Form();
frmMain.Text = "Simple GUI 1 Demo";
frmMain.StartPosition = FormStartPosition.CenterScreen;
frmMain.Closed += new EventHandler(frmMain_Closed);
txt1.Location = new System.Drawing.Point(10,10);
btn1.Text = "Go!";
btn1.Location = new System.Drawing.Point(150,10);
btn1.Click += new EventHandler(btn1_Click);
lblMsg.Text = "System Message Here";
lblMsg.AutoSize = true;
lblMsg.Location = new System.Drawing.Point(10,50);
frmMain.Controls.Add(txt1);
frmMain.Controls.Add(btn1);
frmMain.Controls.Add(lblMsg);
frmMain.Show();
//Application.Run();
}
private static void frmMain_Closed(object sender, System.EventArgs e)
{
Application.Exit();
}
private static void btn1_Click(object s, System.EventArgs e)
{
lblMsg.Text = (txt1.Text.Equals(String.Empty))? "Enter some text";
}
}
Last edited: