//限制輸入的內容必須為數字
private void tb_KeyPress_limite_KeyPress(object sender, KeyPressEventArgs e)
{
//限定輸入的內容僅能有一個小數點
if (e.KeyChar == '.')
{
foreach (char i in (sender as TextBox).Text)//判定textBox1是否有小數點
{
if (i == '.')
e.Handled = true;//有
}
return;
}
// e.KeyChar == (Char)48 ~ 57 -----> 0~9
// e.KeyChar == (Char)8 -----------> Backpace
// e.KeyChar == (Char)13-----------> Enter
if (e.KeyChar == (Char)48 || e.KeyChar == (Char)49 ||
e.KeyChar == (Char)50 || e.KeyChar == (Char)51 ||
e.KeyChar == (Char)52 || e.KeyChar == (Char)53 ||
e.KeyChar == (Char)54 || e.KeyChar == (Char)55 ||
e.KeyChar == (Char)56 || e.KeyChar == (Char)57 ||
e.KeyChar == (Char)13 || e.KeyChar == (Char)8)
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
ls
cd /home/moxa/config
留言
張貼留言