AMZ
AMZ

Reputation: 31

How to change dynamically created button color in Form1 from Form2 in windowsform application

how to change dynamically createtd button color in form1 from form2 in winforms

Upvotes: 1

Views: 43

Answers (2)

AMZ
AMZ

Reputation: 31

I solved my Issue .. This is the code

     var form = (Form)Application.OpenForms["Home"];


     Button _currentBtn = (Button) form.Controls.Find("btnMeal", true)[0];


    _currentBtn.BackColor = Color.SteelBlue;


    _currentBtn.ForeColor = Color.White;

Upvotes: 0

Abi
Abi

Reputation: 165

In Form2

var form = (Form)Application.OpenForms["Form1"];
Button _currentBtn = (Button) form.Controls.Find("button_name", true)[0];
_currentBtn.BackColor = Color.SteelBlue;

Upvotes: 2

Related Questions