tags:

views:

171

answers:

3

So I have a few tabs in the form, and i want it to work like that:

When you click on the tab's name, it becomes editable, and when i stop editing it remains with the new name.

How would i do that with C# and winforms?

+1  A: 

There's no standard Windows control that does this, so you'll either need to look for a third-party control with this functionality (iffy) or write your own control which draws the appropriate edit box on the tab, etc.

mquander
+6  A: 

You can dynamically create a text box and place it over the tab area to make the user think they are editing the tab directly. When the text box loses focus you can then put the typed in value into the tabs property.

Eric
I ended up using that, but implemented it (and a few more features) inside an extended TabControl
kkaploon
That's probably a good idea. I would have done the same.
Eric
+4  A: 

I agree with Eric, regarding how you could do this with the standard TabControl. You could also provide a dialog to do the name change (a slight variation on Eric's suggestion).

However, I would also recommend that you consider rolling your own tabbed control. They're not difficult to create and by rolling your own, you will be able to put in the exact functionality you need in a robust way rather than trying to piece it together from existing components that may not play nicely together.

Jeff Yates