1

I have two Frorms - Form2 and Form3. In Form2 I've created variable checkedText by following way:

 List<string> checkedCheckboxes = new List<string>();
        CheckBox[] checkBoxes = new CheckBox[] { chbts3, chbda3, chbb50, chbg50, chbapc, chbpbw, 
                                            chbbwp, chbwwbw, chbiconscp, chbiconsmile, chbmdm, chbpica,
                                            chbmypim, chbagile, chbscrm, chbwwapo, chbkc, chba50, chbtimetrends,
                                            chbwawe, chbteamcenter, chbvhub, chbgpg, chbpmg, chbd7w, chbsteelwedge,
                                            chbsrs, chbpwrchncosmo, chbavailsvc, chbphweb, chbmrs, chbicondt};
        foreach (CheckBox checkbox in checkBoxes)
        {
            if (checkbox.Checked)
            {
                checkedCheckboxes.Add(checkbox.Text);
            }
        }
        string checkedText = String.Join("|", checkedCheckboxes);

And I'd like to use this variable in Form3. How can I do that without creating any textbox or label. Thanks a lot for any of your advice in advance.

SmithiM
  • 231
  • 3
  • 10

1 Answers1

1

You have to make it a public/internal accessible property on the form class:

class Form2 : Form
{
    public string CheckedText  { get; set; }

    //etc...
}

So when you set your checked text use this property:

CheckedText = String.Join("|", checkedCheckboxes);

Now CheckedText will be available to other forms.

James Dev
  • 2,979
  • 1
  • 11
  • 16