I have a vb.net form that containing 2 richtextbox. The first richtextbox in English and the second in Arabic. How can I change the cursor direction so that its direction turns to the right when entering the Arab richtextbox and to the left when entering the English richtextbox??
Perhaps you mean changing the input language on enter a RichTextBox
control? If that's what you are after, then you need to handle the Enter
event of each RTB
to switch the language through the InputLanguage
class. The class has static properties to get the installed input languages, their cultures, the default and the current input languages.
Add Enter
event handler for each RTB
and handle them as follows:
The English Language RTB
Private Sub enRTB_Enter(sender As Object, e As EventArgs) Handles enRTB.Enter
Dim lang = InputLanguage.InstalledInputLanguages.
Cast(Of InputLanguage).
FirstOrDefault(Function(x) x.Culture.TwoLetterISOLanguageName = "en")
If lang IsNot Nothing Then InputLanguage.CurrentInputLanguage = lang
End Sub
The Arabic Language RTB
Private Sub arRTB_Enter(sender As Object, e As EventArgs) Handles arRTB.Enter
Dim lang = InputLanguage.InstalledInputLanguages.
Cast(Of InputLanguage).
FirstOrDefault(Function(x) x.Culture.TwoLetterISOLanguageName = "ar")
If lang IsNot Nothing Then InputLanguage.CurrentInputLanguage = lang
End Sub