Passing values betwwen Windows Forms in Realtime - Using Delegates and Events
Hi all, in this post I'll explain how to use delegates to pass value to another form. To demonstrate this I'll use windows forms. Task: 1. There is a Windows form called Tool. And there is another Windows form called Register. 2. We need to get the name of the user from the Register form to the Tool form. I have created a Windows form project and named it as BaseNumbers. You can use any number as you like. Then I have designed the 2 forms as bellow. To make the things work we have to use delegates and events. Register Form namespace BaseNumbers { public delegate void RegisterUser(string name); public partial class Register : Form { public event RegisterUser registerUser; public Register() { InitializeComponent(); } private void btnRegister_Click(object sender, EventArgs e) { if (txtUsername.Text != "") { if (registerUser != null) ...