Hi all,
I am using one RichTextBox in C# Windows Application. I need to restrict the user from entering any key from keyboard at certain conditions. so, I wrote the following line of code in keydown event of RichTextBox at .
private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
{
e.SuppressKeyPress = true;
}
This is working fine for English US keyboard. But when i changed my regional settings to Korea and keyboard language to Korean, i can enter the Korean characters (like ?????) even after executing the above statement.
even i have tried with the following code
private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
{
e.SuppressKeyPress = true;
e.Handled = true;
}
but in vain.
Please help.
Thanks in advance. .
Loading
sampath kumarPosted Feb 14, 2012, 12:54 AM
setting "Readonly" property of the richtextbox to true at selected conditions (where i supposed to suppress the key) and again making the "Readonly" property of the richtextbox to "false" in keyup event.
It meets the requirement. Now, it is working fine.
Thanks for your time.
Sam HobbsPosted Feb 13, 2012, 5:18 PM
VulpesPosted Feb 13, 2012, 9:32 AM
Check this link for an example of the latter technique:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keypress.aspx