Advertisement
AalborgHTX

2 vinduer

Apr 23rd, 2020
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApp42
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         Form2 RefTilForm2;
  16.         public Form1()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.  
  21.         private void Form1_Load(object sender, EventArgs e)
  22.         {
  23.             RefTilForm2 = new Form2(this);
  24.             RefTilForm2.Show();
  25.         }
  26.  
  27.         private void btnKnap1_Click(object sender, EventArgs e)
  28.         {
  29.             RefTilForm2.OpdaterForm2();
  30.         }
  31.  
  32.         public void OpdaterForm1()
  33.         {
  34.             lblForm1.Text = lblForm1.Text + "X";
  35.         }
  36.     }
  37. }
  38.  
  39. ---------------------------------------------------------------------
  40.  
  41. using System;
  42. using System.Collections.Generic;
  43. using System.ComponentModel;
  44. using System.Data;
  45. using System.Drawing;
  46. using System.Linq;
  47. using System.Text;
  48. using System.Threading.Tasks;
  49. using System.Windows.Forms;
  50.  
  51. namespace WindowsFormsApp42
  52. {
  53.     public partial class Form2 : Form
  54.     {
  55.         Form1 RefTilForm1;
  56.         public Form2(Form1 KaldendeObjekt)
  57.         {
  58.             InitializeComponent();
  59.             RefTilForm1 = KaldendeObjekt;
  60.         }
  61.  
  62.         public void OpdaterForm2()
  63.         {
  64.             lblForm2.Text = lblForm2.Text + "X";
  65.         }
  66.  
  67.         private void btnKnap2_Click(object sender, EventArgs e)
  68.         {
  69.             RefTilForm1.OpdaterForm1();
  70.         }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement