1- Handler TextBox Key pressed event handler.
Restrict user to type 'Arabic' Text in TextBox
ddanbe commented: Hi Ramy! Nice snippet :) +6
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
char lastChar = e.KeyChar;
//MessageBox.Show(((int)e.KeyChar).ToString());
if (e.KeyChar != 32 && e.KeyChar !=8) //allows space and backspace
{
if (char.IsControl(lastChar) || char.IsDigit(lastChar) || char.IsNumber(lastChar) || char.IsPunctuation(lastChar))
e.Handled = true;
else if (lastChar < 1569)//the start of ascii codes for Arabic chars.
e.Handled = true;
}
}
ddanbe 2,724 Professional Procrastinator Featured Poster
Ramy Mahrous 401 Postaholic Featured Poster
Rajesha N 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.