I added
this->textBox1->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::textBox_KeyPress);
to
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
문제
Can someone modify this for me?
Private Sub NumericKeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(Keys.Back) Then
Else
If Not Char.IsDigit(e.KeyChar) Then
e.Handled = True
Beep()
Else
If Len(TextBox1.Text) > 0 Then
If Val(TextBox1.Text) > 105097565 Then
e.Handled = True
Beep()
End If
End If
End If
End If
End Sub
Or tell me how is: 1.NumericKeyPress event? 2.How to say e.KeyChar? 3.How to say IsDigit? 4.How to say Chr(ASCII number)? 5.How to handle e.Key? 6.How to system beep?
I tried:
private: System::Void textBox1_KeyPress( Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e )
{
if(e->KeyChar == (Char)8)
{}
else
{
if (!Char::IsDigit(e->KeyChar))
{
e->Handled = true;
}
else
{
if (textBox1->Text->Length > 0)
{
if (int::Parse(textBox1->Text) > 105097565)
{
e->Handled = true;
}
}
}
}
}
but it didn't work.
해결책
I added
this->textBox1->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::textBox_KeyPress);
to
#pragma region Windows Form Designer generated code
void InitializeComponent(void)