Sunday 15 January 2012

Add textbox data to an object after button click c# -


I pass a custom associate object in a field and I want to add a username and password after a button click event I am The problem is that I have a scope for object button button events. How do I get around this? Even I have the code ...

  public partial class frmCredentials: form {public frm credentials (associate_command) {InitializeComponent (); // Keep the values ​​for MES system and username. This.label1.Text = "Please enter your" + _associate.mesType + "password; Change the form color for this.txtUsername.Text = _associate.userName; // MES system (_associate.mesType ==" Factory Works " } {This.BackColor = System.Drawing.Color.Aquamarine;} and {this.backer = system.downing.color.lellow;}} private zeros btnOk_Click (object sender, EventArgs e) {// Make sure the collaborative field (This.txtUsername.Text == "" || this.txtPassword.Text == "") {MessageBox.Show ("You must enter a username and password"); Return;} This. Visibl E = false; return;}}    

the solution is your associate Object and then set the instance field value in your constructor.

  Public partial class frmCredentials: Form {Private Associate _Size; Public FRM credentials (Associate_socialnet) {Initialization (); This._associate = Keep the values ​​for _associate; // MES system and username. This.label1.Text = "Please enter your" + _associate.mesType + "password; Change the form color for this.txtUsername.Text = _associate.userName; // MES system (_associate.mesType ==" Factory Works " } {This.BackColor = System.Drawing.Color.Aquamarine;} and {it.backer = system.downings.color.lellow;}} private zeros btnOk_Click (object sender, EventArgs e) {// Here you have an example field of You can use the _associate object in the form // Make sure the affiliate has filled the field if (this.txtUsername.Text == "" || this .txtPassword.Text == "") {MessageBox.Show ("You must enter a username and password"); return;} This.Visible = false; return;}}    

No comments:

Post a Comment