//gmcs /r:System.Windows.Forms.dll /r:System.Drawing.dll Program.cs
//mono Program.cs
using System;
using System.Drawing;
using System.Windows.Forms; //System.Windows.Forms.dll
class Program{
[STAThread]
public static void Main(string[] args){
if(args.Length == 0) return;
string name = args[0];
Application.EnableVisualStyles();
Application.Run(new Form1(name));
}
}
class Form1 : Form{
private Button button;
public Form1(string name){
this.Height = 200;
this.Width = 700;
Label label = new Label();
label.Text = "command line: " + name;
label.Font = new System.Drawing.Font("Veranda", 18);
label.Height = this.Height;
label.Width = this.Width;
this.button = new Button();
this.button.Text = "Ok";
this.button.Width = this.Width / 2;
this.button.Height = 50;
this.button.Location = new Point(1,50);
this.button.Click += new EventHandler(this.button_click);
this.Controls.Add(this.button);
this.Controls.Add(label);
}
private void button_click(object sender, EventArgs args){
this.Close();
}
}
Listed below are links to blogs that reference this entry: Passing command line arguments to a Form (C#).
TrackBack URL for this entry: http://www.rootsilver.com/mt-tb.cgi/97
Leave a comment