-5

Im creating a windows forms application using C#.

I have an integer and it contains a value that needs to be printed in the form next in the application. How can I have it available for use in the second form ?

2 Answers2

0

There are so many methods to pass data between forms in Windows application:

  • Using constructor
  • Using objects
  • Using properties
  • Using delegates

Try to this link: http://www.codeproject.com/Articles/14122/Passing-Data-Between-Forms

Rai Vu
  • 1,595
  • 1
  • 20
  • 30
0

Create a new Constructor that allows you to pass it in while still calling the parameterless constructor that probably initializes the controls for the form in some *.designer.cs.

// example

private int m_passedInValue;

public MyForm2()
{
  InitializeConstrols();
}

public MyForm2(int thePassedValue)
 : this()
{
  m_passedInValue = thePassedValue;
}

// the form1 call
void SomeOpenFormMethod()
{
  var form2 = new MyForm2(20);
  form2.Show();
}
Landern
  • 374
  • 2
  • 5