Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to be able to get a variable such as the name of the tab when its pressed and then with that information use that variable in a query i want to run.
How can i do that?
I thought about switch and cases but i was told i couldn´t do it that way, what other ways are there?

What I have tried:

I have tried Switch and Cases and now i don´t know what i can do.
Posted
Updated 22-Feb-21 4:58am

You could subscribe to the Selected[^] event, which triggers when the active tab is changed. From there you have access to the TabControlEventArgs.TabPage property, from which you could get either the index or the tab text.

You can then use this index or the text to perform whatever operation is needed.
 
Share this answer
 
Comments
Member 15080037 22-Feb-21 10:54am    
Oh i see, thank you.
There are several way to do this. One is implementig tab-change event and use the tab name. Something like:

C#
private void tabControl1_Selecting(object sender, TabControlCancelEventArgs e)
{
   string tabName = e.TabPage.Name;

  // Implement your query based on tabName
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900