using System; using System.Windows.Forms; using System.Drawing; using System.IO; class ex : Form { TextBox tb1 = new TextBox(); ex() { Text = "hello"; tb1.Location = new Point(0, 25); 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) { SaveFileDialog sfd = new SaveFileDialog(); sfd.DefaultExt = "txt"; if (sfd.ShowDialog() == DialogResult.OK) { File.WriteAllText(sfd.FileName, tb1.Text); } } [STAThread] static public void Main() { Application.Run(new ex()); } }