0

I have an application that needs to click on button located on tab pages. So for example:

Tabcontrol has Tabpage1, Tabpage2, .... TabpageN

and each tabpage has a buttonX that performs a taskX.

Now supposing, I'm on TabPage1 and I want to Click ButtonX on Tabpage3 without changing tabindex/selectedindex. How can I do that?

1 Answer 1

1

Generally one would use PerformClick but I've noticed it failing on TabControl. So if not dependent on EventArgs, create a sub method for the click event e.g.

private void button1_Click(object sender, EventArgs e)
{
    Button1PerformClick();
}

private void Button1PerformClick()
{
    MessageBox.Show("Button1");
}

Than calling

private void button2_Click(object sender, EventArgs e)
{
    Button1PerformClick();
}

Doesn't matter in regards to which tab the button is on in this case.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.