Well I have been struggling with this all day, and searching google to no avail here is what I did as suggested
Code:
public ref class EnterTextBox : System::Windows::Forms::TextBox{
public:virtual bool IsInputKey(Keys keydata) override{
if (keydata == Keys::Enter)
return true;
else
return TextBox::IsInputKey(keydata);
}
};
I subclassed TextBox and override IsInputKey
Then I changed textBox1 to type EnterTextBox
and processed my KeyPressEvent as follows:
Code:
private: System::Void textBox1_KeyPress(System::Object^ sender, KeyEventArgs^ e){
if (e->KeyCode == Keys::Enter) {
this->listBox1->Items->Add(this->textBox1->Text);
++number_of_listitems;
this->textBox1->Text = "";
e->Handled = true;
}
}
This is simply supposed to add the text in the textbox to a listbox when the enter key is pressed. The code compiles but still doesn't seem to process Enter as the system bell ring sounds when enter is pressed.
Signed, Stumped