-1

我如何删除呈现“Enter”的键?我希望程序在用户输入时显示“请输入 Espace 或 Tab”,然后删除此 Enter 键。谢谢!

private: System::Void richTextBoxCommentaire_KeyDown(System::Object^  sender, System::Windows::Forms::KeyEventArgs^  e) {
             if (e->KeyValue == (char)13)
             {
                    MessageBox::Show ("Please enter Espace or Tab");
//To delete this Key??
                 }
             }
4

1 回答 1

0

sorry, using the previewKeyDown should have worked but try the next method :

Use the KeyDown event to filter the desired keys by setting the suppressKeyPress to true as you can see in the example below (the example is in C# for readability but conversion to C++ CLI should be trivial :) :

private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
{
    e.SuppressKeyPress = e.KeyCode == Keys.Enter;
}
于 2013-10-14T15:16:22.180 回答