Will it be difficult to implement a solution to forcing text to be written from the right side of the textbox to the left? So when I type a character, the IBeam appears on the left side of the typed letter instead of the right. :wave:
Printable View
Will it be difficult to implement a solution to forcing text to be written from the right side of the textbox to the left? So when I type a character, the IBeam appears on the left side of the typed letter instead of the right. :wave:
Set the RightToLeft property of the textbox to Yes and its automatically taken care of. :D
is that what it does... thanks RD :D
Yup, in VB6 it was dependent upon your version of Windows for it to be enabled. Although now its independent of the OS. :thumb:
Cool. Usually if a property has no visible effect I tend to ignore it :P
There are allot of properties that have no design time effect. If you want to know what a property does you should check the
MSDN help file or MSDN On-Line. Your missing out if you dont. ;)
Wait, its not resolved :( All that happened, was that it invert the effect of the TextAlight property. So if TextAlign is set to Right, then it makes it Left but the next char will still appear on the right side of the previous char.
You'd have to use an RTL font such as Arabic or Hebrew to get that effect.
The other thing you could do is to capture each key being entered and place it yourself at the other 'end' of the string.
But the RTL property works correctly, but doesnt reverse the fonts.
The only problem I have with this that this event also manages the pressing of backspace. So if I press backspace, it will jump one character back, thus making backspace useless and a big hassle for the user. This code is in my textbox's KeyPress event.VB Code:
If e.KeyChar.IsDigit(e.KeyChar.ToString) = False And e.KeyChar.IsControl(e.KeyChar.ToString) = False Then e.Handled = True ' Here I can put the SendKey to send the pressing of the ' Left Arrow to windows so that it jumps onto the right side. End If
I would still like to resolve this. I can modify the code but can sopmeone please tell me how i call the left direction key? If i can get that, then hopefully i can resolve this.
Just thinking out loud here but you could set the cursor position with textbox.SelectedText = x and TextBox.SelectionLength = 0
Her's my two cents:
VB Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress e.Handled = True Select Case e.KeyChar Case ControlChars.Back If TextBox1.SelectionLength = 0 Then TextBox1.SelectionLength = 1 End If TextBox1.SelectedText = "" TextBox1.SelectionStart += 1 Case Else TextBox1.SelectedText = e.KeyChar If TextBox1.SelectionStart > 0 Then TextBox1.SelectionStart -= 1 End Select End Sub
This doesn't deal with the Del-key or with any of the Controls like Crtl-Z 'N stuff. But it's something.