How To Call a Button Click From Another Button in C#.Net?


In this post, we will discuss how we can call a button click from another button click in C#.Net. Remember this is available in windows application not in a web application.


It is easy to call a button click on another button click. Check the full code below:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void btnFirst_Click(object sender, EventArgs e)
{
lblResult.Text = “This is the First Button!”;
}

private void btnSecond_Click(object sender, EventArgs e)
{
btnFirst.PerformClick();
}
}
}

Here in the second button click event we are calling the first button click and the result will be shown as “This is the First Button!”. Check the figure for output.

You can also check my previous post:

Asp.Net MVC Life Cycle and Various State Management Techniques in Asp.Net MVC

How to set up session state in our ASP.NET Core and MVC Core Web applications?



Asp.Net MVC 5 Cascading DropDownList Using jQuery

Check out Best Alternative to InfoPath -> Try Now

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →