[CODE lang="csharp" title="form1"]using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
public static Label label1=new Label();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
label1.Location = new Point(0, 0);
this.Controls.Add(label1);
Button btnForm2 = new Button();
btnForm2.Text = "Form2";
btnForm2.Location = new Point(0,25);
btnForm2.Click += BtnForm2_Click;
this.Controls.Add(btnForm2);
Timer sayac = new Timer();
sayac.Interval = 1000;
sayac.Tick += Sayac_Tick;
sayac.Start();
}
private void BtnForm2_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.Show();
}
private void Sayac_Tick(object sender, EventArgs e)
{
rastGele();
}
void rastGele()
{
Random rnd = new Random();
label1.Text = rnd.Next(0, 100000).ToString();
}
}
}[/CODE]
[CODE lang="csharp" title="form2"]using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp3
{
public partial class Form2 : Form
{
Label lbl1 = new Label();
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
lbl1.Location = new Point(0, 0);
this.Controls.Add(lbl1);
Form1.label1.TextChanged += Label1_TextChanged;
}
private void Label1_TextChanged(object sender, EventArgs e)
{
lbl1.Text = Form1.label1.Text;
}
}
}
[/CODE]