using System; using System.Windows.Forms; class Student { private string name; private double gpa; public string Name { get { return name; } set { name = value; } } public double Gpa { get { return gpa; } set { gpa = value; } } } class Widget : Form { TextBox textBox1; TextBox textBox2; Button button; Student student; public static void Main(string[] args) { Application.Run(new Widget()); } public Widget() { student = new Student(); student.Name = "Jeff"; student.Gpa = 4.0; textBox1 = new TextBox(); textBox2 = new TextBox(); textBox1.DataBindings.Add(new Binding("Text", student, "Name")); textBox2.DataBindings.Add(new Binding("Text", student, "Gpa")); button = new Button(); button.Click += new EventHandler(testButton_Click); TableLayoutPanel pan = new TableLayoutPanel(); pan.ColumnCount = 3; pan.ColumnCount = 1; pan.Controls.Add(textBox1, 0, 0); pan.Controls.Add(textBox2, 1, 0); pan.Controls.Add(button, 2, 0); this.Controls.Add(pan); } private void testButton_Click(object sender, EventArgs e) { MessageBox.Show("Name: " + student.Name + " GPA: " + student.Gpa); } }