如何获取在 numericupdown silverlight 控件中输入的字符串值?

发布于 2024-11-29 01:05:18 字数 761 浏览 4 评论 0原文

我正在使用银光数字上下控制。控件设置为十进制数。

最大限制为 28,最小限制为 -28

增量步长为 0.25

在荷兰文化中使用此控件,因此它接受 1,2 形式的值

并将其转换为 1.2

3 ,5 并将其转换为 3.5

10,3 并将其转换为 10.3

27,5 并将其转换为 27.5

现在我的问题是,当尝试输入值

1.2,它会将其转换为 12,00(我希望 1.2 应该反映为 1,2

我如何实现它?

或如何获取在 NumeriCupDown 控件中输入的字符串值作为字符串。

这样我就可以按照我想要的方式对字符串进行操作?

我尝试使用事件

private void NumericUpDown_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {

        }

但对我没有多大帮助。

请找到附图,在非公共成员中,我正在获取 NumericUpDown 控件的 Text 属性,但无法在我的代码中实现该属性,如何获取该 TEXT 属性。

在此处输入图像描述

I am using silver-light numeric up-down control. Control is set for decimal numbers.

Maximum limit 28 and minimum limit is -28

Increment steps are 0.25

using this control in dutch culture so it accept value in the form

1,2 and converts it in to 1.2

3,5 and converts it in to 3.5

10,3 and converts it in to 10.3

27,5 and converts it in to 27.5

Now my issue is that when try to enter value

1.2 it converts it into 12,00 (I want 1.2 should reflect to 1,2)

How do I achieve it?

or How do I get string value entered in the NumeriCupDown control as string.

so I can act on string as I want?

I tried using event

private void NumericUpDown_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {

        }

but does not help me lot.

Please find attached image where in Non Public member i am getting Text Property of NumericUpDown control but not able to implement that in my code how do i Get that TEXT property.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

临走之时 2024-12-06 01:05:18

创建 NumericUpDown 的子类并重写 ParseValue 方法:

public class MyNumericUpDown : NumericUpDown {

  protected override double ParseValue(string text)
  {
     // Change text to whatever you want
     string newText = FixText(text);

     // Call base implementation.
     base.ParseValue(newText);
  }

  private static string FixText(string inputText) {
    // DO YOUR STUFF HERE.
  } 
}

Create a subclass of NumericUpDown and override the ParseValue method:

public class MyNumericUpDown : NumericUpDown {

  protected override double ParseValue(string text)
  {
     // Change text to whatever you want
     string newText = FixText(text);

     // Call base implementation.
     base.ParseValue(newText);
  }

  private static string FixText(string inputText) {
    // DO YOUR STUFF HERE.
  } 
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文