Joel Bwana

Joel Bwana

  • NA
  • 24
  • 1.9k

Passing data from 2 forms to same textbox c#

Aug 12 2020 2:35 PM
I have two forms FormA and FormB. Each has combobox prefiled with data from database. I can pass data from each of these box to another formC but I have to comment out a section of the code each time. Is there a way to pass such data(when I click submit button) depending on which form I am working with? 
 
Here is what my code looks like...
 
FormA(Source)
 
public static string authcode = "";
 
 
private void btnok_Click(object sender, EventArgs e)
{
authcode = cmbselectexam.SelectedItem.ToString();
Questions qs = new Questions();
qs.Show();
this.Hide();
}
 
FormB(Another source)
public static string setauthcode = "";
 
setauthcode =txtauthorizationcode.Text;
Questions qs = new Questions();
this.Hide();
qs.Show();
 
  
FormC(recepient)
private void Questions_Load(object sender, EventArgs e)
{
//txtauthorizationcode.Text = TestDetails.setauthcode;
txtauthorizationcode.Text = EditQuestions.authcode;
}
 
 
 
 

Answers (12)