Joan Venge
Joan Venge

Reputation: 331042

How can I add a button to the empty area of a TabControl in Winforms?

Grabbed the images from a similar question in WPF. Basically I want the extra buttons to do different things, not create or delete tabs. Actions related to the current tab which are gonna be the same for all the tabs in a single TabControl.

When I try to place my buttons on that area, the visual studio designer throws my control away, back to their original position. It doesn't allow me to put anything there.

Can this be done?

alt text http://www.freeimagehosting.net/uploads/92ca1b0a8c.png

alt text http://www.freeimagehosting.net/uploads/ff0d08e0ed.png

Upvotes: 0

Views: 418

Answers (2)

Sergii Kudriavtsev
Sergii Kudriavtsev

Reputation: 10512

For specifically that visual experience I'd just create a separate tab with header "+" and add some logic on switching to it - so it will perform some other action instead of switching. The same can be done with multiple tabs I guess.

UPDATE

Actual code for this:

private void TabControl1_Selecting(Object sender, TabControlCancelEventArgs e) 
{
    if (e.TabPage... /* Do check whether some of your special TabPages is being selected */)
    {
        e.Cancel = true;

        // All other TabPage-specific actions here
        ...
    }
}

Upvotes: 2

Matt
Matt

Reputation: 1431

So it looks like they are using a tab as a button here. I would imagine they have the tab controls index change event fire a new tab into the tab control and force focus to it.

Upvotes: 0

Related Questions