我需要使用MaskedTextBox
的基本功能。我可以使用5位数字掩码,但是我想改变的东西很少。眼下盒看起来像这样:Windows窗体 - 自定义MaskedTextBox
有两种东西,我不喜欢。首先 - Prompt char
这是低于_
。我删除了字段值以便将其留空(因为我希望它出现),但是这给出了一个错误 - The property value is invalid
。那么有没有办法摆脱这些下划线? - 其次所以我做一个皈依我用我的实体属性是整数类型之一这个值:
if (txtNumOfAreas.Text != "")
{
string temp = txtNumOfAreas.Text;
bool result = Int32.TryParse(temp, out convertValue);
if (result)
{
entity.AreasCnt = convertValue;
}
else
{
MessageBox.Show(Resources.ERROR_SAVE, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
else
{
entity.AreasCnt = null;
}
,除非有人决定做实验,并插入类似_1__5_
然后转换失败,工作正常,但首先我想让数字只能一个接一个地写出来。这也可能吗?
一点点使用它:[SO](http://stackoverflow.com/questions/1459797/hiding-the-promptchar-for-nets-maskedtextbox)和[MSDN](http://msdn.microsoft.com/zh-cn/ COM/EN-US /库/ system.windows.forms.maskedtextbox.mask(VS.90)的.aspx)。 – 2013-03-13 15:40:24