using System; using System.Windows.Forms; using System.IO; class ex : Form { TextBox tb1 = new TextBox(); ex() { Text = "hello"; tb1.Dock = DockStyle.Fill; tb1.Multiline = true; Controls.Add(tb1); MenuStrip ms = new MenuStrip(); Controls.Add(ms); ToolStripMenuItem File = new ToolStripMenuItem("File"); ms.Items.Add(File); ToolStripMenuItem mi = new ToolStripMenuItem("Save"); mi.Click += new EventHandler(Example); File.DropDownItems.Add(mi); } void Example(object sender, EventArgs e) { File.WriteAllText(@"C:\test\test1.txt", tb1.Text); } static public void Main() { Application.Run(new ex()); } }