一つのメソッドの中にまとめる方法を教えてください。
C#
1 2コード 3 4 private void textHeight_KeyPress(object sender, KeyPressEventArgs e) 5 { 6 //.KeyChar = 押されたキーに対応する文字を取得または設定します。 7 //数値と小数点とバックスペース以外の入力は不可 8 if ((e.KeyChar < '0' || e.KeyChar > '9') && e.KeyChar != '\b' && e.KeyChar != '.') 9 { 10 //.Handled = 取得またはを示す値を設定するかどうか、 KeyPress イベントが処理します。 11 e.Handled = true; 12 //e.Handled = Trueと入れると、キャンセルできる。 13 } 14 } 15 16 17 /// <summary> 18 /// 体重のテキストボックス入力時 19 /// </summary> 20 /// <param name="sender"></param> 21 /// <param name="e"></param> 22 private void textWeight_KeyPress(object sender, KeyPressEventArgs e) 23 { 24 //.KeyChar = 押されたキーに対応する文字を取得または設定します。 25 //数値と小数点とバックスペース以外の入力は不可 26 27 if ((e.KeyChar < '0' || e.KeyChar > '9') && e.KeyChar != '\b' && e.KeyChar != '.') 28 { 29 30 //.Handled = 取得またはを示す値を設定するかどうか、 KeyPress イベントが処理します。 31 e.Handled = true; 32 //e.Handled = Trueと入れると、キャンセルできる。 33 } 34 }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。