RadDateTimePicker - SelectAll Text Not Working

2 posts, 1 answers
  1. Abdul
    Abdul avatar
    1 posts
    Member since:
    Feb 2017

    Posted 15 Feb Link to this post

    Hello,

    I am using RadDateTimePicker (Version 2016.1.328.45) in my WPF application. The requirement is such that I need to select all text inside the DateTimePicker when the user clicks inside it. For this purpose, I am using the GotFocus event, inside which I am getting the TextBox inside the DateTimePicker by the method FindChildByType<TextBox>() and then calling SelectAll() on this TextBox.

     

    This doesn't work. Any suggestions or workarounds on how to achieve this?

    Thanks.

  2. Answer
    Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    503 posts

    Posted 16 Feb Link to this post

    Hi Abdul,

    I am here providing the solution I have already sent you in the ticket you have raised as it might be helpful for other users.

    You can handle the PreviewMouseDown event of the DateTimePicker and apply the following logic:
     
    private void dtPicker_PreviewMouseDown(object sender, MouseButtonEventArgs e)
           {
               if ((e.OriginalSource as UIElement).ParentOfType<RadWatermarkTextBox>() != null)
               {
                  e.Handled = true;
                  (e.OriginalSource as UIElement).ParentOfType<RadWatermarkTextBox>().Focus();
               }
           }

    Regards,
    Stefan Nenchev
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top