Description: In recent HALCON doing C # programming and, to use a single example of changing the value of the parameter of the parent form of a subform. This example is a simplified version
1, click system settings
2, the pop-subform, after which the modified input parameter points Edit button
3, click the OK button, the subform off, change the value of the main form textbox
4, the singleton procedure is as follows:
public class Student { // Create Singleton internal static class method Private Student () {} // private constructor class the Nested { internal static readonly Student instance = new Student(); } public static Student Instance { get { return Nested.instance; } } // create the field and its properties Private String name; public String the Name { get { return name; } set { name = value; } } private int chinses; public int Chinses { get { return chinses; } set { chinses = value; } } private int math; public int Math { get { return math; } set { math = value; } } }
5, the child window procedure
public Setting() { InitializeComponent(); } STU Student = Student.Instance; // create a single class of embodiments private void Setting_Load(object sender, EventArgs e) { } private void BtnChange_Click(object sender, EventArgs e) { stu.Name = the this .textBoxName.Text; // the sub-display window textbox property value assigned to the field stu.Chinses = Convert.ToInt32 ( the this .textBoxChinese.Text); stu.Math = Convert.ToInt32(this.textBoxMath.Text); }
6, the parent form program
STU = Student.Instance Student; // Create a singleton Private void MainForm_Load ( Object SENDER, EventArgs E) { the this .tBName.Text = " Weber " ; // main window display content loading the this .tBChinese.Text = Convert.ToString ( 89 ); the this .tBMath.Text = Convert.ToString ( 90 ); } private void ToolStripButton1_Click(object sender, EventArgs e) { Setting mySetting = new Setting(); mySetting.ShowDialog (); // sub pop-up window the this .tBName.Text = stu.Name; // value field attribute value assigned textbox the this .tBMath.Text = Convert.ToString (stu.Math); the this .tBChinese.Text = Convert.ToString (stu.Chinses); }
7. Conclusions
A novice, if wrong, please correct me!