Wes
Wes

Reputation: 55

Implementing windows form c++ tab selected event

I've been relying on the auto generator of the microsoft visual studio 2010 to generate event handlers such as the click events for radio buttons and picture boxes. However, the editor does not generate an event for handling selected tabs. The purpose of this event handler is to to call a function that changes the controls within the tabs and what tool strip items are enabled for users to use such as save, save as, open, etc.

Not sure how the code is suppose to be implemented without relying on the MCS2010 script writer for generating it.

Upvotes: 0

Views: 1396

Answers (1)

Seth Carnegie
Seth Carnegie

Reputation: 75150

Are you talking about TabControl? If so, you can go to the Properties of the TabControl and go the the Events, and double click in the Selected event box and it will create a function to handle the event. You can use the TabPageIndex of the TabControlEventArgs^ that gets passed to that callback to know which tab was selected, like this:

System::Void tabControl1_Selected(System::Object^  sender, System::Windows::Forms::TabControlEventArgs^  e) {
    MessageBox::Show("Tab index " + e->TabPageIndex + " was selected");
}

You then can do whatever you want like change your toolbars, etc. to match which tab is open.

Upvotes: 2

Related Questions