Actually Windows Forms applications do not need any special code for handling Tamil: they support Unicode. Make sure that you use a font which supports the Tamil characters.
In case you think of a Form with several textboxes, some for input in English, some for input in Tamil, and you would like to ease the input for the user by setting the appropriate input method automatically, you can do as follows:
Add handlers for the
Enter
and
Leave
events of a
TextBox
. In the event handlers, change the
InputLanguage
acordingly.
On my computer, I did not install Tamil, but e.g. Thai on a German Windows. For changing between Thai and German I can do:
private void txtThai_Leave(object sender, EventArgs e)
{
ChangeInputLanguage("Deutsch");
}
private void txtThai_Enter(object sender, EventArgs e)
{
ChangeInputLanguage("Thai");
}
private void ChangeInputLanguage(string languageName)
{
InputLanguage newLanguage = GetInputLanguageByName(languageName);
InputLanguage.CurrentInputLanguage = newLanguage;
}
private InputLanguage GetInputLanguageByName(string languageName)
{
foreach (InputLanguage lang in InputLanguage.InstalledInputLanguages)
{
if (lang.LayoutName.ToLower().StartsWith(languageName.ToLower()))
return lang;
}
throw new ApplicationException(string.Format("Requested input language {0} not available", languageName));
}
Replace "Deutsch" and "Thai" with "English" and "Tamil" - and it should work for you.