我会用逗号分隔的数字, 我所寻求的是完全一样千位分隔符与columnGridView逗号,当用户键入
,但这一问题的解决方案没有奏效对我来说,因为我在gridview而不是文本框中的列中执行此操作。
我做了什么至今(类的一部分列在GridView):
当我在列中键入12345:
public override string Text
{
get { }
set { base.Text = GetFormattedText(value); }
}
protected override void OnTextChanged(System.EventArgs e)
{
base.OnTextChanged(e);
Text = GetFormattedText(Text);
}
protected virtual string GetFormattedText(string text)
{
string strText = text.Replace(",", "");
decimal decValue = System.Convert.ToDecimal(strText);
strText = decValue.ToString("#,##0");
return strText;
}
那么,与这一段代码发生它变得---> 51234
Pleae如果我的说法是不明确的告诉我,我会解释更
尝试增加'base.SelectionStart = base.Text.Length;'的'Text'二传手后' base.Text = GetFormattedText(value);' – Pikoh
为什么在属性的setter和事件方法的覆盖中使用你的方法? – juharr
@juharr是的,代码有点奇怪,因为首先它甚至不会编译...也许如果OP发布真正的代码,我们可以提供帮助。 – Pikoh