Advertisement
solidsnake

C#MakingFormsAppearUsingForms

May 19th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. FORM 1 -------------------------------------------------------------------------------------------
  2.     public partial class Form1 : Form
  3.     {
  4.         public Form1()
  5.         {
  6.             InitializeComponent();
  7.         }
  8.  
  9.         private void button1_Click(object sender, EventArgs e)
  10.         {
  11.             Form2 f = new Form2();
  12.             f.Name = textBox1.Text;
  13.             f.setName();
  14.             f.ShowDialog();
  15.  
  16.             labelForm2Dish.Text = f.Lieblingsessen;
  17.  
  18.         }
  19.     }
  20.  
  21. FORM 2 -------------------------------------------------------------------------------------------
  22.  
  23.     public partial class Form2 : Form
  24.     {
  25.         private string formOneName;
  26.        
  27.         public string Name
  28.         {
  29.             set
  30.             {
  31.                 formOneName = value;
  32.             }
  33.         }
  34.  
  35.         public string Lieblingsessen
  36.         {
  37.             get
  38.             {
  39.                 return textBox1.Text;
  40.             }
  41.         }
  42.  
  43.         public void setName()
  44.         {
  45.             label3.Text = formOneName;
  46.         }
  47.         public Form2()
  48.         {
  49.            
  50.             InitializeComponent();
  51.            
  52.         }
  53.  
  54.         private void button1_Click(object sender, EventArgs e)
  55.         {
  56.             Close();
  57.         }
  58.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement