Sonia Rehman
Sonia Rehman

Reputation: 105

who to write multilanguage or only( urdu) in wpf application textbox with vb.net?

This code is not working. What is done by this code? plz help me!

Public Sub urdu_GotFocus(ByVal InputLang As InputLanguage)
   If InputLanguage.InstalledInputLanguages.IndexOf(InputLang) = -1 Then
        Throw New ArgumentOutOfRangeException()
   End If
    InputLanguage.CurrentInputLanguage = InputLang
End Sub

if i try this code

Private Sub urdu_TextChanged(sender As Object, e As TextChangedEventArgs, ByVal InputLang As InputLanguage) Handles urdu.TextChanged
    If InputLanguage.InstalledInputLanguages.IndexOf(InputLang) = 1 Then
        Throw New ArgumentOutOfRangeException()
    End If
    InputLanguage.CurrentInputLanguage = InputLang
End Sub

then this error occurred Error 1 Method 'Private Sub urdu_TextChanged(sender As Object, e As System.Windows.Controls.TextChangedEventArgs, InputLang As System.Windows.Forms.InputLanguage)' cannot handle event 'Public Event TextChanged(sender As Object, e As System.Windows.Controls.TextChangedEventArgs)' because they do not have a compatible signature. C:\Users\atk\documents\visual studio 2013\Projects\WpfApplication1\WpfApplication1\insert.xaml.vb 146 126 WpfApplication1 what i am doing wrong please guide me?

Upvotes: 0

Views: 948

Answers (2)

Ameer Chand
Ameer Chand

Reputation: 51

when you installed Arabic/Urdu or any other language . if you want to install input language sea above post.

then make simple code of one line.

it will type the desire language as you selected from Task bar.

 Private Sub txtUrdu_GotFocus(sender As Object, e As EventArgs) Handles txtUrdu.GotFocus
    **InputLanguage.CurrentInputLanguage = System.Windows.Forms.InputLanguage.CurrentInputLanguage**

End Sub

Upvotes: 0

Zeddy
Zeddy

Reputation: 2089

Thank you for clarifying what it is you are trying to do, The objective was not clear from your original post.

First of all, you should make sure that you have URDU installed in your KEYBOARDS/LANGUAGES - Note this is not the same as having an URDU font!

If you use windows the installation of a new keyboard should be similar to below step #1 to step #7

If you already have the URDU KEYBOARD installed, then jump right to the end of my solution and review the code there.

Step #1 Open CONTROL PANEL and select CLOCK/LANGUAGES/REGION enter image description here

Step #2 Select REGIONAL AND LANGUAGE OPTIONS enter image description here

Step #3 Click on CHANGE KEYBOARDS and OTHER INPUT METHODS enter image description here

Step #4 Click On ADD button

enter image description here

Step #5 Select URDU language and click on OK button enter image description here

Step #6 Confirm that the URDU language is listed and Click On Okay button enter image description here

Step #7 Click On Okay button enter image description here

Once you have added URDU to your installed languages list Continue from here.

Using the code below:

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  Dim counter As Integer = Nothing
  If InputLanguage.InstalledInputLanguages.Count > 0 Then
    For counter = 0 To InputLanguage.InstalledInputLanguages.Count - 1
       ComboBox2.Items.Add(InputLanguage.InstalledInputLanguages(counter).LayoutName)
    Next
  End If
End Sub

Private Sub ComboBox2_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
  If InputLanguage.InstalledInputLanguages.IndexOf(InputLanguage.InstalledInputLanguages(ComboBox2.SelectedIndex)) = (-1) Then
    Throw New ArgumentOutOfRangeException()
  Else
    InputLanguage.CurrentInputLanguage = InputLanguage.InstalledInputLanguages(ComboBox2.SelectedIndex)
  End If
End Sub

You should be able to select URDU language, And then type in urdu in any textbox

enter image description here

enter image description here

Another Update

Hello Sonia, I think this is what you wanted? As per the comments in your comments below?

Private Sub txtEnglish_GotFocus(sender As Object, e As System.EventArgs) Handles txtEnglish.GotFocus
  InputLanguage.CurrentInputLanguage = InputLanguage.InstalledInputLanguages(0)
End Sub

Private Sub txtUrdu_GotFocus(sender As Object, e As System.EventArgs) Handles txtUrdu.GotFocus
  InputLanguage.CurrentInputLanguage = InputLanguage.InstalledInputLanguages(1)
End Sub

Maybe this link maybe of help to you Sonia? http://www.codeproject.com/Articles/38751/Building-Multilingual-WPF-Applications

Upvotes: 3

Related Questions