【问题标题】:how to get string value entered in numericupdown silverlight control?如何获取在 numericupdown silverlight 控件中输入的字符串值?
【发布时间】:2011-10-25 18:06:46
【问题描述】:

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

上限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 属性。

【问题讨论】:

    标签: c# silverlight toolkit numericupdown


    【解决方案1】:

    创建 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.
      } 
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-10
      • 2023-03-29
      • 2014-01-09
      • 1970-01-01
      • 2011-09-27
      相关资源
      最近更新 更多