I have 2 buttons on my Form.
My question is if button1 can activate button2 in any way.
Is it possible to write any code inside button1 that will execute/activate the code inside button2 ?

If the code is run from more than one event, you should refactor it into a method:

void button1_Click(Object^ sender, EventArgs^ e)
{
  // Stuff for button 1

  Button2Stuff();
}

void button2_Click(Object^ sender, EventArgs^ e)
{
  Button2Stuff();
}

void Button2Stuff()
{
  // Stuff for button 2
}

You can also fire an event handler directly since it's just another method:

void button1_Click(Object^ sender, EventArgs^ e)
{
  // Stuff for button 1

  button2_Click(this, EventArgs::Empty);
}

void button2_Click(Object^ sender, EventArgs^ e)
{
  // Stuff for button 2
}

Thank you. I will play around and see what I can do...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.