Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
「ENTER」キーが押されたときにキャレットがテキスト ボックスの次の行に移動しないようにするにはどうすればよいですか? 言い換えれば、テキストボックスで「ENTER」または「RETURN」キーを無効にする方法は?
OnKeyDownイベントを書くことができます。を使用しe.SuppressKeyPressて、キーを処理することを .NET に伝えることができます。このようなもの:
OnKeyDown
e.SuppressKeyPress
if (e.KeyCode == Keys.Enter) { e.SuppressKeyPress = true; }
をご覧くださいTextBox.AcceptsReturn。
TextBox.AcceptsReturn