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

How to get the length of selected numbers?

5 Answers 122 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 03 Dec 2009, 11:13 PM
I need a way to find out what is the selected length when user highlights number in NumericUpDown control.

5 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 04 Dec 2009, 12:47 PM
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.
0
Kevin
Top achievements
Rank 1
answered on 07 Dec 2009, 10:26 PM
Hello,

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

    Thanks!

-Kevin
0
Accepted
Valeri Hristov
Telerik team
answered on 08 Dec 2009, 09:06 AM
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.
0
Gabe
Top achievements
Rank 1
answered on 19 Apr 2011, 08:54 PM
IS there any update on this. I would like to have a better way to get the SelectedText for the NumericUpDown control.
0
Valeri Hristov
Telerik team
answered on 20 Apr 2011, 12:07 PM
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
Tags
NumericUpDown
Asked by
Kevin
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Kevin
Top achievements
Rank 1
Gabe
Top achievements
Rank 1
Share this question
or