2

Hi, this is really basic stuff but i can't seem to find a simple answer on the web. I'm using Visual Studio 2010, doing C# and I have two tabs in a basic tab control and a calculate button outside of the Tabcontrol, that I need to calculate different sums depending on which tab the user has selected.

My initial thought was to use an if statement along the lines of:

private void calculateButton_Click(object sender, EventArgs e)
        {
            if (tabControl.tab1.selected == true)
            {
                 MessageBox.Show("whatever");
            }
            else
            {
                 MessageBox.Show("doesnt matter");
            }
        }

Any help would be great as you can probably tell I'm very new to programming, so thanks for taking time to answer

SchmitzIT
  • 9,227
  • 9
  • 65
  • 92

2 Answers2

0

Try this:

private void calculateButton_Click(object sender, EventArgs e)
{
    if (tabControl.SelectedTab == tab1)
    {
        MessageBox.Show("whatever");
    }
    else
    {
        MessageBox.Show("doesnt matter");
    }
}
Hamlet Hakobyan
  • 32,965
  • 6
  • 52
  • 68
0
private void calculateButton_Click(object sender, EventArgs e)
        {
            if (tabControl.SelectedTab == tab1)
            {
                 MessageBox.Show("whatever");
            }
            else
            {
                 MessageBox.Show("doesnt matter");
            }
        }
Karthik
  • 2,391
  • 6
  • 34
  • 65