Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
Lost focus when active tabcontrol
posted

Hi All,

I have the following problem and need help

I have 1 UltratabControl. Each tabcontrol has its own UltraTextEditor. When displaying a tab, then select all text of a Ultratexteditor field instead of focus at the end of the textbox. 

Please help me. Thanks

Parents
No Data
Reply
  • 960
    Suggested Answer
    Offline posted

    Hello Ngoc Trinh,

    If you want to select all text in a UltraTextEditor when a tab is displayed, you may want to give focus to the ultraTextEditor and call its SelectAll() method when the form is displayed or the selected tab is changed.

    --------------
    [Sample code]
        private void Form1_Shown(object sender, EventArgs e)
        {
            ultraTextEditor1.Focus();
            ultraTextEditor1.SelectAll();
        }

        private void ultraTabControl1_SelectedTabChanged(object sender, SelectedTabChangedEventArgs e)
        {
            UltraTab selectedTab = e.Tab;

            if(selectedTab.TabPage.Controls.Count > 0)
            {
                // Assuming that the first control on the selected tab is of UltraTextEditor.
                UltraTextEditor textEditor = selectedTab.TabPage.Controls[0] as UltraTextEditor;
                textEditor.Focus();
                textEditor.SelectAll();
            }
        }
    --------------

    Could you give it a try? I hope this will help.

Children
No Data