>>using System; >>using System.Drawing; >>using System.Collections; >>using System.ComponentModel; >>using System.Windows.Forms; >>using System.Data; >> >>namespace WindowsApplication14 >>{ >> /// <summary> >> /// Summary description for Form1. >> /// </summary> >> public class Form1 : System.Windows.Forms.Form >> { >> private WindowsApplication14.UserControl1 userControl11; >> private System.ComponentModel.Container components = null; >> private System.Windows.Forms.Button button1; >> >> private Class1 class1 = new Class1(); >> >> public Form1() >> { >> InitializeComponent(); >> } >> >> protected override void Dispose( bool disposing ) >> { >> if( disposing ) >> { >> if (components != null) >> { >> components.Dispose(); >> } >> } >> base.Dispose( disposing ); >> } >> >> #region Windows Form Designer generated code >> /// <summary> >> /// Required method for Designer support - do not modify >> /// the contents of this method with the code editor. >> /// </summary> >> private void InitializeComponent() >> { >> this.userControl11 = new WindowsApplication14.UserControl1(); >> this.button1 = new System.Windows.Forms.Button(); >> this.SuspendLayout(); >> // >> // userControl11 >> // >> this.userControl11.Location = new System.Drawing.Point(24, 24); >> this.userControl11.N1 = new System.Decimal(new int[] { >> 0, >> 0, >> 0, >> 0}); >> this.userControl11.N2 = new System.Decimal(new int[] { >> 0, >> 0, >> 0, >> 0}); >> this.userControl11.Name = "userControl11"; >> this.userControl11.Size = new System.Drawing.Size(152, 144); >> this.userControl11.TabIndex = 0; >> // >> // button1 >> // >> this.button1.Location = new System.Drawing.Point(56, 184); >> this.button1.Name = "button1"; >> this.button1.TabIndex = 1; >> this.button1.Text = "Display"; >> this.button1.Click += new System.EventHandler(this.button1_Click); >> // >> // Form1 >> // >> this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); >> this.ClientSize = new System.Drawing.Size(272, 230); >> this.Controls.Add(this.button1); >> this.Controls.Add(this.userControl11); >> this.Name = "Form1"; >> this.Text = "Form1"; >> this.Load += new System.EventHandler(this.Form1_Load); >> this.ResumeLayout(false); >> >> } >> #endregion >> >> [STAThread] >> static void Main() >> { >> Application.Run(new Form1()); >> } >> >> >> private void Form1_Load(object sender, System.EventArgs e) >> { >> this.userControl11.DataBindings.Clear(); >> this.userControl11.DataBindings.Add("N1", this.class1, "N1"); >> this.userControl11.DataBindings.Add("N2", this.class1, "N2"); >> this.userControl11.DataBindings.Add("C1", this.class1, "C1"); >> } >> >> private void button1_Click(object sender, System.EventArgs e) >> { >> MessageBox.Show("N1:"+this.class1.N1.ToString() + Environment.NewLine + "N2:"+this.class1.N2.ToString() + Environment.NewLine+ "C1:"+this.class1.C1.ToString()); >> } >> } >> >> >> public class UserControl1 : System.Windows.Forms.UserControl >> { >> private System.Windows.Forms.NumericUpDown numericUpDown1; >> private System.Windows.Forms.NumericUpDown numericUpDown2; >> private System.Windows.Forms.CheckBox checkBox1; >> private System.ComponentModel.Container components = null; >> >> public decimal N1 >> { >> get{return this.numericUpDown1.Value;} >> set{this.numericUpDown1.Value = value;} >> } >> >> public decimal N2 >> { >> get{return this.numericUpDown2.Value;} >> set{this.numericUpDown2.Value = value;} >> } >> >> public bool C1 >> { >> get{return this.checkBox1.Checked;} >> set{this.checkBox1.Checked = value;} >> } >> >> public UserControl1() >> { >> InitializeComponent(); >> } >> >> protected override void Dispose( bool disposing ) >> { >> if( disposing ) >> { >> if(components != null) >> { >> components.Dispose(); >> } >> } >> base.Dispose( disposing ); >> } >> >> #region Component Designer generated code >> /// <summary> >> /// Required method for Designer support - do not modify >> /// the contents of this method with the code editor. >> /// </summary> >> private void InitializeComponent() >> { >> this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); >> this.numericUpDown2 = new System.Windows.Forms.NumericUpDown(); >> this.checkBox1 = new System.Windows.Forms.CheckBox(); >> ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); >> ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); >> this.SuspendLayout(); >> // >> // numericUpDown1 >> // >> this.numericUpDown1.Location = new System.Drawing.Point(40, 32); >> this.numericUpDown1.Name = "numericUpDown1"; >> this.numericUpDown1.Size = new System.Drawing.Size(56, 20); >> this.numericUpDown1.TabIndex = 0; >> // >> // numericUpDown2 >> // >> this.numericUpDown2.Location = new System.Drawing.Point(40, 72); >> this.numericUpDown2.Name = "numericUpDown2"; >> this.numericUpDown2.Size = new System.Drawing.Size(56, 20); >> this.numericUpDown2.TabIndex = 1; >> // >> // checkBox1 >> // >> this.checkBox1.Location = new System.Drawing.Point(8, 8); >> this.checkBox1.Name = "checkBox1"; >> this.checkBox1.TabIndex = 2; >> this.checkBox1.Text = "checkBox1"; >> // >> // UserControl1 >> // >> this.Controls.Add(this.checkBox1); >> this.Controls.Add(this.numericUpDown2); >> this.Controls.Add(this.numericUpDown1); >> this.Name = "UserControl1"; >> this.Size = new System.Drawing.Size(152, 144); >> ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); >> ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit(); >> this.ResumeLayout(false); >> >> } >> #endregion >> } >> >> >> public class Class1 >> { >> private decimal n1 = 1; >> public decimal N1 >> { >> get{return this.n1;} >> set{this.n1 = value;} >> } >> private decimal n2 = 2; >> public decimal N2 >> { >> get{return this.n2;} >> set{this.n2 = value;} >> } >> >> private bool c1 = true; >> public bool C1 >> { >> get{return this.c1;} >> set{this.c1 = value;} >> } >> } >> >> >>} >>