This is a migrated thread and some comments may be shown as answers.

Set focus to textbox in editable tab header

8 Answers 91 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Roman
Top achievements
Rank 1
Roman asked on 10 Aug 2010, 07:11 PM
Hi,

I've looked over the thread regarding making the tab header's editable. I've got that working, so far, and that's great. I would now like to add functionality to this so that when a context menu is opened from right clicking on the tab header, the user can click on the "Rename" item from the context menu and the textbox in the header will receive focus and have it's contents selected so the user can simply type in the new name of the tab header and click on the Enter key to save the changes and show the label with the new changes. I've tried setting with control.focus and control.selectall methods, but I cannot get focus to that textbox.

Any ideas on how to implement something like that?

Thanks
Roman

8 Answers, 1 is accepted

Sort by
0
Miro Miroslavov
Telerik team
answered on 13 Aug 2010, 09:28 AM
Hi Roman,

You can try first to make sure that the Silverlight plug-in has the focus:
System.Windows.Browser.HtmlPage.Plugin.Focus();

And after that focus the textBox, but invoked in the dispatcher thread.
Dispatcher.BeginInvoke(() => { textText.Focus();});

Can you give it a try and let us know if it works for you.

Kind regards,
Miro Miroslavov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Roman
Top achievements
Rank 1
answered on 13 Aug 2010, 03:48 PM
Hi Miro,

Thanks for your reply. However, I do not know where I should be incorporating the code you showed me into the editable tab header example shown here:

http://www.telerik.com/help/silverlight/radtabcontrol-how-to-make-the-tab-headers-editable.html

This is the example I would like to add functionality to have a "Rename" option in a right click menu on the header to setfocus to and selectall the text in the textbox.

Also, if you could show me examples in VB, that would be great since that's what I'm using.

Thanks,
Roman
0
Miro Miroslavov
Telerik team
answered on 17 Aug 2010, 12:54 PM
Hi Roman,

You should use this two lines instead of the "control.Focus()" that you said previously you've tried. (I've tried setting with control.focus and control.selectall methods, but I cannot get focus to that textbox.).
Hope will work for you.

Sincerely yours,
Miro Miroslavov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Roman
Top achievements
Rank 1
answered on 18 Aug 2010, 06:16 PM
Hi Miro,

Yes, this did work for me. Thank you so much for your help.

Sincerely,
Roman
0
Pranama Moorthy
Top achievements
Rank 1
answered on 09 Dec 2010, 01:07 PM
Hi,

I have an editable RadtabControl, and below is the feature that I want.

When I actually click on the editable Control (textbox), to rename the RadTab, then that tab should be selected. By The example that is given, when I actually try to edit a text for the header, the radTab Containing the Text is not highlighted (not selected).

In Short, I want the selected item to be that RadTabITem on which I am actually making a header change. Is there  a way to let the RadTabItem know that its header is being changed, so it needs to be selected?




0
Petar Mladenov
Telerik team
answered on 14 Dec 2010, 08:07 PM
Hi Pranama Moorthy,

Do you enter in the EditMode with mouse double click?  If so, on the first click of the mouse, the RadTabItem`s Header gets selected and the second click makes the Header be in EditMode. You can inspect that in the attached solution. Please also note that in one moment, you can have several TabItems that are in EditMode, which is expected behavior. If this is not what you had in mind, please elaborate more on how you enter the edit mode and do you want a single editable tab header at a moment. Thank you in advance for your cooperation.

Regards,
Petar Mladenov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Pranama Moorthy
Top achievements
Rank 1
answered on 12 Jan 2011, 06:02 PM
Hi Petar,

 Apologizes for a late response. My Requirements are something as below

1. Only when the tab is selected (Active), should it allow editing. (Other tabs which are not active, should not be editable).
2. The user should then be able to edit only the active tab, by double clicking it.

Hope this is feasible.

Regards,
Pranama
0
Petar Mladenov
Telerik team
answered on 17 Jan 2011, 03:39 PM
Hi Roman,

I made a workaround for you that uses the PreviewSelctionChanged event of the TabControl. Basically, I turn off the Edit mode of  the RadTabItems. Hope this will fit in your scenario. Thank you in reporting this bug in the example from the article. I logged this in our internal system and updated your telerik points accordingly.

All the best,
Petar Mladenov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
TabControl
Asked by
Roman
Top achievements
Rank 1
Answers by
Miro Miroslavov
Telerik team
Roman
Top achievements
Rank 1
Pranama Moorthy
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or