回覆列表
  • 1 # 使用者3977671246998

    限制長度:設定maxlength屬性

    遮蔽非數字鍵輸入:新增keypress事件

    private void textBox1_KeyPress(object sender, KeyPressEventArgs e){

    e.Handled = !(Char.IsNumber(e.KeyChar) || e.KeyChar == "\b");

    }

    替換全形(中文)數字字元為半形(英文)字元:新增textchange事件

    private void textBox1_TextChanged(object sender, EventArgs e){

    for (int i=0;i

    if (textBox1.Text[i] >= "0" && textBox1.Text[i]

    textBox1.Text = textBox1.Text.Replace(textBox1.Text[i], (char)(textBox1.Text[i] - "0" + "0"));

    }

    門道我說不出多少,辦法也比較笨,看看是否符合要求

  • 中秋節和大豐收的關聯?
  • 為什麼天安愛立方產品剛出不久,就停售?