im entering data into textboxes. If the checkbox is checked i wanna pass the data in the textbox and the checkbox.text to form2. Here i need to show what was entered as a review stage and submit back to form1 whether or not to submit the data or edit it again.
Form1 Code
namespace bankaccount
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void depositSubmit_Click(object sender, EventArgs e)
{
Form2 formreview = new Form2(dateTimePicker1.Text, check_checkBox1.Text, check_deposit1.Text);
formreview.Show();
}
}
}
Form2 Code
namespace
bankaccount{
public partial class Form2 : Form
{
public Form2(string strTextBox, string check1, string check2)
{
InitializeComponent();
label1.Text = strTextBox;
label2.Text = check1;
label3.Text = check2;
}
}
}

Passing Checkbox.Text if checked
adlammons
To communicate back to form1 when form2 is modeless, you need to set up a delegate. Or you can use a modal form (ShowDialog instead of Show ) and put a property on form2 which you can check when it closes.
I should add that if the strings are being passed conditionally, they should probably be properties you set, rather than constructor arguments.
msbh88
You have no choice but to use 10 if statements, unless you can pass your strings as a collection ( that is, if they all go to the same place and you can just pass an array of strings as one parameter ). In this case, it can also be a constructor argument. Then you can use foreach on the controls collection or another collection that holds your check boxes, and check each one, adding it's text if it is checked.
JA
ok makes sense, but how do i check the to see if the check boxes are checked and then pass checkbox.text i dont want 10 if or switch statements.
can i do something like:
private checkstatus()
{ check status on all checkboxes, whatever is true return checkbox.text
}