How to get the length of selected numbers?

6 posts, 1 answers
  1. Kevin
    Kevin avatar
    9 posts
    Member since:
    Mar 2009

    Posted 03 Dec 2009 Link to this post

    I need a way to find out what is the selected length when user highlights number in NumericUpDown control.
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 04 Dec 2009 Link to this post

    Hello Kevin,

    Unfortunately RadNumericUpDown does not provide a way to get/set the selection of its internal TextBox. You could try the following code:
    var textBox = RadNumericUpDown1.ChildrenOfType<TextBox>().FirstOrDefault();
    if (textBox != null)
    {
        // manupulate the selection here
    }

    but I strongly recommend using it only for testing purposes, since it might add performance penalty on your application.

    I will add this request to the product backlog and we will consider it for its future development.

    All the best,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Kevin
    Kevin avatar
    9 posts
    Member since:
    Mar 2009

    Posted 07 Dec 2009 Link to this post

    Hello,

          I tried your sample code, but it always return the null. So I couldn't get the internal reference to TextBox.

        Thanks!

    -Kevin
  5. Answer
    Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 08 Dec 2009 Link to this post

    Hi Kevin,

    I suppose that you are trying to call my code too early, e.g. in a Loaded event or the page constructor - at this time the template of RadNumericUpDown is not applied yet and the TextBox is not created, hence the method returns an empty array. You could try the following:
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();

            this.RadNumericUpDown1.ApplyTemplate();
            var length = this.RadNumericUpDown1.ChildrenOfType<TextBox>()[0].SelectionLength;
        }
    }

    Regards,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Gabe
    Gabe avatar
    29 posts
    Member since:
    Mar 2011

    Posted 19 Apr 2011 Link to this post

    IS there any update on this. I would like to have a better way to get the SelectedText for the NumericUpDown control.
  7. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 20 Apr 2011 Link to this post

    Hello Gabe,

    This functionality has not changed and I still cannot set a specific delivery date for this feature.

    Kind regards,
    Valeri Hristov
    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
Back to Top
DevCraft banner