---
title: "I want to store the button text which called the window form"  
description: "I want to store the button text which called the window form"  
author: "Anonymous User"  
published: 2013-09-04  
updated: 2013-09-04  
canonical: https://www.mindstick.com/forum/1438/i-want-to-store-the-button-text-which-called-the-window-form  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# I want to store the button text which called the window form

On [form](https://www.mindstick.com/forum/6/multi-form-mfc-application) 1 I want to [store](https://www.mindstick.com/articles/13125/tips-to-increase-sales-of-your-woocommerce-store) the [name](https://yourviews.mindstick.com/view/87450/how-to-generate-a-brand-name-using-linkedin-comprehensive-guide) of the button which called this form so that i can [execute](https://www.mindstick.com/interview/49/how-can-i-execute-a-php-script-using-command-line) some [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) depending upon the [button click](https://www.mindstick.com/forum/790/form-gets-submiited-twice-on-button-click)

```
button bt1=new button();button bt2=new button();private void b1_click(object sender, eventargs e){    form1 f1=new form1();    f1.show();}private void b2_click(object sender, eventargs e){    form1 f1=new form1();    f1.show();}
```

## Replies

### Reply by Sumit Kesarwani

Hi Chintoo,\

There are multiple ways of doing this, I suggest one of the following ways

Using the forms constructor:

ie

```
form1 f1 = new form1("MyButtonName");and then in the constructor of the formpublic form1(string buttonName){    this.ButtonName = buttonName;}or setting the property manuallyform1 f1 = new form1();f1.ButtonName = "MyButtonName";
```

I prefer using the former, as it forces you to specify the [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) that creates the new form.


---

Original Source: https://www.mindstick.com/forum/1438/i-want-to-store-the-button-text-which-called-the-window-form

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
