Hi All,
Is it possible for a user to rename a tab? I know I can do it programmatically using Tab.text, but I'm looking for a way of the existing tab text getting selected/highlighted, and then the user being able to type a new name over the top.
Just like in MS Excel, when the user clicks on a sheet tab and chooses "Rename".
Is this acheivable, and if not, what is a good alternative for handling user tab renaming?
Any info appreciated,
Scott Pearce
Here is how I roll this smoke...Merry Christmas....
Here is the Tab MouseUp Event that gets the ball rolling...dont forget to use the text editors lost focus to hide itself when its all said and done...
It goes like this: Extract the tab, map the tab, create some geometric info, assign that info to the tab, pull up the context menu, assign the tab to the tools in the pop menu, use the geometric info to pop up the menu, then respond to the tool click and extract the prior assignments first from the tool, and then its tag (the tab)...to place your edit box
This works like a charm...Cheers
Here is the Tool Click Event...notice how we query the Tool.Tag to see if is packing a Tab, then check to see if the Tab is packing a Rectangle...we just burrow into the tool and query whats it packing to decide what to do...and in this case we display the Tab Rename edit box on target, on time....in fact parsing the Tool.Tag for its type is a slick way to handle click events...it lets you sift out the ordinary from the extraordinary in one step...
I constantly leverage the Tag property like this to extend functionality without bogging a GUI code set down with class wide variables...and other such nonsense...such as unecessary inheritence...
There is no end to how sophisticated you can get with this, as you can create custom objects, and type check against custom interfaces and pack it into a single Tag property if required..there are tons of solutions to common problems using this method...
Now thats what I call a Tag Team...
Not bad. The only suggestion I'll make is that you use the following code to find a tab's rect so you don't have to do so much work manually searching for the edges:
UIElement tabElement = this.tabAddress.UIElement.GetDescendant( typeof( TabItemUIElement ), tab );
if ( tabElement != null ){ Rectangle tabRect = tabElement.Rect; // ...}
Mike Dour"]Not bad. The only suggestion I'll make is that you use the following code to find a tab's rect so you don't have to do so much work manually searching for the edges: UIElement tabElement = this.tabAddress.UIElement.GetDescendant( typeof( TabItemUIElement ), tab ); if ( tabElement != null ){ Rectangle tabRect = tabElement.Rect; // ...}
Awsome.....I didn't know about that UIelement thing...I am still only a couple of onion layers deep in the Infra stuff
CW
Hi all,
This worked brilliantly, thanks!!!
Just a quick note, I wanted to go one step further by allowing the user to be able to add a tab and then immediately go into edit mode. I initially had prolems in that the tabControl.UIElement.GetDescendant(typeof(TabItemUIElement), myNewTab) was returning a null. To resolve this, I had to refresh the tabControl (myTabControl.Refresh()) immediately after adding my new tab and before attempting to go into edit mode.
Hope this helps.Assad
i figured it out... the textbox should be created outside the ultratabcontrol
Hi.
I just tried to apply the code, the problem i have is that the ultratexteditor is behind the tab and i cant get it to the front.
any suggestions? thx