using System;
using System.Windows.Forms;
using System.Drawing;
public class Class1
{
public Class1()
{
}
static void Main()
{
CreatForm();
}
public static void CreatForm()
{
Form form1 = new Form();
TextBox textBox1 = new TextBox();
textBox1.Text = "Hello world!";
textBox1.Name = "textBox1";
textBox1.Width = 200;
textBox1.Height = 100;
textBox1.Multiline = true;
textBox1.ScrollBars = ScrollBars.Vertical;
textBox1.AcceptsReturn = true;
textBox1.AcceptsTab = true;
textBox1.WordWrap = true;
textBox1.Location = new Point(10,10);
Button button1 = new Button();
button1.Text = "Show";
button1.Location = new Point(10, textBox1.Height + 20);
button1.Click += new EventHandler(button1_Click);
Button button2 = new Button();
button2.Text = "Cancel";
button2.Location = new Point(button1.Right + 10, textBox1.Height + 20);
form1.AcceptButton = button1;
form1.CancelButton = button2;
form1.Controls.Add(button1);
form1.Controls.Add(button2);
form1.Controls.Add(textBox1);
form1.StartPosition = FormStartPosition.CenterScreen;
form1.ShowDialog();
}
public static void button1_Click(Object sender, EventArgs e)
{
Button button = (Button)sender;
MessageBox.Show(button.Parent.Controls["textBox1"].Text.Trim());
}
}