Tuesday 15 July 2014

c# - How do pass parameters from 1 form to another? -


The main form of my program is where I keep a collection of values ​​from other sub-forms. Subtype is giving me an error for some reason:

non-static field

requires an object reference. This is my main form:

  public partial square frm_SystemLog: form {public frm_SystemLog () {InitializeComponent (); } Public string text box values ​​{// meet other values ​​to get value. This return Lesson 1 box. Text; } Set {textBox1.Text = value; }} Private Zero frm_SystemLog_Load (object sender, EventArgs e) {log frm_LoginMenu = new log (); Frm_LoginMenu.ShowDialog (); }}   

This is my sub form:

  public partial class log: form {public logs ( ) {InitializeComponent (); } Private Zero Button 2_Click (Object Sender, EventArgs E) {// This is where error is frm_SystemLog.TextBoxValue = "SomeValue"; This.Close (); }}   

You should create an asset in your log form, then set your value Do this when you are entering this

  // Public string value in the log form {get; Set;}   

Then select dialogresult in the properties of your button 2 of the log form and set it to fit your button in 2 click event

  Private Zero Button 2_Click (Object Sender, EventArgs e) {MyValue = "SomeValue"; // no need to stop, dialogresult will do this ...}   

then do this in your frm_SystemLog form

  private zeros frm_SystemLog_Load (Object sender, EventArgs e) {log frm_LoginMenu = new log (); Frm_LoginMenu.ShowDialog (); If (frm_LoginMenu.ShowDialog () == DialogResult.OK) {this.TextBoxValue = frm_LoginMenu.MyValue; }}   

This should solve your problem.

No comments:

Post a Comment