0

i hope this is old question , but yet i need a solution from you . I have a class i.e public partial class form1 and i have initialized some strings here . i want to use the string values in another form . how can i do that .

public partial class Form1 : Form
{

    public string firstrange ="" ;
    public string firstrange1 ="";
    public string lastrange = "";
    public string lastrange1 = "";
    public string Receivedrange = "";
    public string Receivedrange1 = "";



public Form1()
        {
            InitializeComponent();
         }

// while loading form1 , i'm adding some values to the strings from CSV

 firstrange = WorksheetSourcee1.UsedRange.Cells[1, 1].Value.ToString();
 firstrange1 = WorksheetSourcee1.UsedRange.Cells[1, 2].Value.ToString();
}

Now i want use these strings in another form2 , i just need to get the same string values. can anybody suggest me about it.

MSG
  • 161
  • 1
  • 2
  • 13

1 Answers1

1

You can use form2 constructor to get the required parameters.

 public Form2 (string yourParam)
 {
 InitializeComponent(); 
 }

And in the current form just pass those parameters:

Form2 = new Form2 (parameterName);
Form2 .ShowDialog();
Ron537
  • 990
  • 1
  • 9
  • 20