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 ?
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 ?
There are so many methods to pass data between forms in Windows application:
Try to this link: http://www.codeproject.com/Articles/14122/Passing-Data-Between-Forms
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();
}