Click here to Skip to main content
15,908,015 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I've a windows application in which the input can be given in any language we select like hindi, Arabic etc..

My problem is while typing in textbox, at first the key which I type is displayed and immediately it is converted into the language I selected previously..

My requirement is not to view the key I pressed before converting into another language.

This is done in Similar Web application using Pre-Render() event..

But do not know in windows app... any suggestion plz..

Below is my code:

C#
private void txtSchoolName_KeyUp(object sender, KeyEventArgs e)
        {

            string str;
            Class2 cls = new Class2();
            if (_lang == "te")       //te-Telugu language
            {
                str = cls.TeluguText(txtSchoolName.Text);
                txtSchoolName.Text = str;
             txtSchoolName.SelectionStart = txtSchoolName.Text.Length;
            }




Thanks in advance,
Ravi kamesh..
Posted
Updated 8-Sep-12 14:29pm
v3
Comments
Sergey Alexandrovich Kryukov 6-Sep-12 2:55am    
You do something we have not idea about, and still you are asking what's wrong. How would we know?
Show some code sample or explain it more. Use "Improve question" above.
--SA

1 solution

Instead of KeyUp(), use KeyPress() event to capture your keyboard presses. Then set e.Handled = true:

C#
private void txtSchoolName_KeyPress(object sender, KeyEventArgs e)
 {

 string str;
 Class2 cls = new Class2();
 if (_lang == "te") //te-Telugu language
 {
 e.Handled = true;
 str = cls.TeluguText(txtSchoolName.Text);
 txtSchoolName.Text = str;
 txtSchoolName.SelectionStart = txtSchoolName.Text.Length;
 }
 
Share this answer
 
Comments
prk@cp 9-Sep-12 23:51pm    
when this is implemented, im unable to type anything in the textbox...
j.yanga 11-Sep-12 21:03pm    
Start with the basic keypress event handler code:

private void txtSchoolName_KeyPress(object sender, KeyEventArgs e)
{
e.Handled = true;
txtSchoolName.Text = "text";
}

Then add your business logic one line at a time to see where the problem is. Also, you have to disable any other event handlers for txtSchoolName textbox to avoid any confusion when your debugging your code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900