using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace Example74 { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.ListBox lstActivities; private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox txtActivity; private System.Windows.Forms.Button btnActivity; private System.Windows.Forms.TextBox txtResult; private System.Windows.Forms.Label label2; private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem mnuExit; private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.MenuItem mnuFont; private System.Windows.Forms.FontDialog fontDialog1; private System.Windows.Forms.MenuItem mnuColor; private System.Windows.Forms.ColorDialog colorDialog1; private System.Windows.Forms.MenuItem menuItem3; private System.Windows.Forms.MenuItem menuItem4; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.lstActivities = new System.Windows.Forms.ListBox(); this.label1 = new System.Windows.Forms.Label(); this.txtActivity = new System.Windows.Forms.TextBox(); this.btnActivity = new System.Windows.Forms.Button(); this.txtResult = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.mainMenu1 = new System.Windows.Forms.MainMenu(); this.menuItem1 = new System.Windows.Forms.MenuItem(); this.mnuExit = new System.Windows.Forms.MenuItem(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.mnuFont = new System.Windows.Forms.MenuItem(); this.fontDialog1 = new System.Windows.Forms.FontDialog(); this.mnuColor = new System.Windows.Forms.MenuItem(); this.colorDialog1 = new System.Windows.Forms.ColorDialog(); this.menuItem3 = new System.Windows.Forms.MenuItem(); this.menuItem4 = new System.Windows.Forms.MenuItem(); this.SuspendLayout(); // // lstActivities // this.lstActivities.Items.AddRange(new object[] { "Amusement Park", "Boat Trip", "Dance ", "DDR", "Dinner", "Movie"}); this.lstActivities.Location = new System.Drawing.Point(72, 40); this.lstActivities.Name = "lstActivities"; this.lstActivities.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; this.lstActivities.Size = new System.Drawing.Size(120, 56); this.lstActivities.Sorted = true; this.lstActivities.TabIndex = 0; this.lstActivities.SelectedIndexChanged += new System.EventHandler(this.lstActivities_SelectedIndexChanged); // // label1 // this.label1.Location = new System.Drawing.Point(16, 120); this.label1.Name = "label1"; this.label1.TabIndex = 1; this.label1.Text = "Add an Activity"; // // txtActivity // this.txtActivity.Location = new System.Drawing.Point(144, 120); this.txtActivity.Name = "txtActivity"; this.txtActivity.TabIndex = 2; this.txtActivity.Text = ""; // // btnActivity // this.btnActivity.Location = new System.Drawing.Point(88, 160); this.btnActivity.Name = "btnActivity"; this.btnActivity.TabIndex = 3; this.btnActivity.Text = "Add Activity"; this.btnActivity.Click += new System.EventHandler(this.btnActivity_Click); // // txtResult // this.txtResult.Location = new System.Drawing.Point(24, 232); this.txtResult.Name = "txtResult"; this.txtResult.Size = new System.Drawing.Size(232, 20); this.txtResult.TabIndex = 4; this.txtResult.Text = ""; // // label2 // this.label2.Location = new System.Drawing.Point(24, 208); this.label2.Name = "label2"; this.label2.TabIndex = 5; this.label2.Text = "Result:"; // // mainMenu1 // this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem1, this.menuItem2, this.menuItem3}); // // menuItem1 // this.menuItem1.Index = 0; this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.mnuExit}); this.menuItem1.Text = "&File"; // // mnuExit // this.mnuExit.Index = 0; this.mnuExit.Text = "E&xit"; this.mnuExit.Click += new System.EventHandler(this.mnuExit_Click); // // menuItem2 // this.menuItem2.Index = 1; this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.mnuFont, this.mnuColor}); this.menuItem2.Text = "F&ormat"; // // mnuFont // this.mnuFont.Index = 0; this.mnuFont.Text = "Font"; this.mnuFont.Click += new System.EventHandler(this.mnuFont_Click); // // mnuColor // this.mnuColor.Index = 1; this.mnuColor.Text = "Color"; this.mnuColor.Click += new System.EventHandler(this.mnuColor_Click); // // menuItem3 // this.menuItem3.Index = 2; this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem4}); this.menuItem3.Text = "&Help"; // // menuItem4 // this.menuItem4.Index = 0; this.menuItem4.Text = "About"; this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(292, 273); this.Controls.Add(this.label2); this.Controls.Add(this.txtResult); this.Controls.Add(this.btnActivity); this.Controls.Add(this.txtActivity); this.Controls.Add(this.label1); this.Controls.Add(this.lstActivities); this.Menu = this.mainMenu1; this.Name = "Form1"; this.Text = "Computer Club Event Sign Up"; this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } private void btnActivity_Click(object sender, System.EventArgs e) { lstActivities.Items.Add(txtActivity.Text); txtActivity.Clear(); } private void lstActivities_SelectedIndexChanged(object sender, System.EventArgs e) { string result = ""; foreach (String activity in lstActivities.SelectedItems) result += activity + " "; txtResult.Text = result; } private void mnuExit_Click(object sender, System.EventArgs e) { Application.Exit(); } private void mnuFont_Click(object sender, System.EventArgs e) { fontDialog1.Font = txtResult.Font; if (fontDialog1.ShowDialog() != DialogResult.Cancel) { txtResult.Font = fontDialog1.Font; } } private void mnuColor_Click(object sender, System.EventArgs e) { colorDialog1.Color = txtResult.ForeColor; if (colorDialog1.ShowDialog() != DialogResult.Cancel) { txtResult.ForeColor = colorDialog1.Color; } } private void menuItem4_Click(object sender, System.EventArgs e) { MessageBox.Show("Computer Club Demo"); } } }