0

hi there,

i have a tab control with 3 tab in a form in C#.NET, and also i have a button which shold be doign adding rows to the datagrid view. how can i code the button so that when the active tab is tab on to add a row to it datagrid view, how can i do this,

thanx
appriciate a lot

4
Contributors
5
Replies
10
Views
7 Years
Discussion Span
Last Post by umair.sabri
0

Use the SelectedIndex property of the tab control to identify the current tab.
Or use the SelectedTab property to directly access the current TabPage.

0

Use the SelectedIndex property of the tab control to identify the current tab.
Or use the SelectedTab property to directly access the current TabPage.

hey but when i used the code below only the Message box Topic Action will be running.y is that
the else part does not run at all

hey any solution

thanxxx

private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl1.TabIndex == 0)
            {
                MessageBox.Show("Topic Action");
            }
            else
                MessageBox.Show("nothing");
        }
1

The TabIndex property is the UI Tab order index not the selected tab of the TabControl.
Use tabControl1.SelectedIndex == 0

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.