-3

Basically I have created a program which records customer details, when they enter the details, the information needs to appear into the other form when a button is pressed, I am new to c# so detailed help would be appreciated.

Rémi
  • 3,867
  • 5
  • 28
  • 44
DanB3195
  • 31
  • 1
  • 6

2 Answers2

1

Here is an article I wrote about passing values around between Windows Forms (it includes variations depending on how the forms are related to one another) a while ago. Here it is: http://colinmackay.co.uk/2005/04/22/passing-values-between-forms-in-net/

If you are using WPF (and I can't quite tell if you are or not, but I suspect a beginners assignment would be more tending towards WinForms anyway) then the article may not be as much use as WPF does things a little differently.

I hope it helps.

Colin Mackay
  • 18,736
  • 7
  • 61
  • 88
1

If you are using windows form then you will have to set up some properties which will get and set values on the second form and then pass the values from the 1st form. This is just one of the techniques of passing values.

//Code on your form 2
private string strClass;
private int iRollNo;
..
  public string StrClass
    {
      get { return this.strClass; }
      set { this.strClass= value; }
     }

    public int IRollNo
    {
      get { return this.iRollNo; }
      set { this.iRollNo= value; }
    }

 //code on form1
  Form2 objFrom2 = new Form2();
  objFrom2.strClass= "10th";
  objFrom2.iRollNo= 1;
  objFrom2.ShowDialog(); //show the form.
Shahid Manzoor Bhat
  • 1,307
  • 1
  • 13
  • 32