Answered by:
right to left in multilane textbox???

Question
-
hi
I want the cursor position to be from right to left in the multiline textbox in C# forms Application
Friday, October 14, 2011 9:47 AM
Answers
-
-
Set the RightToLeft property of the textbox to true. But be sure that you text box contains RTL language characters like Arabic, then only it will make sense.
If you are developing a multicultured application, you can take support of inbuilt feature called localization
Friday, October 14, 2011 9:57 AM -
There's no built-in way for you to set that AFAIK, but you can implement the behavior yourself.
First, add an event handler on KeyPress event in your form's constructor:
this.textBox1.KeyPress += new KeyPressEventHandler(textBox1_KeyPress);
And then implement the following:
void textBox1_KeyPress(object sender, KeyPressEventArgs e) { this.textBox1.Select(0, 0); }
This will place the cursor at the side of latest entered charactor.
How to handle delete and backspace is left for you to implement.
Friday, October 14, 2011 10:08 AMAnswerer -
Hi srieja,
Welcome to the MSDN forum.
As far as I know you can realize right to left by
property. But if you want to start from textBox's bottom,
it is hard to realize(you need to realize a new control).
If you want to show a textfile in a textbox and hope
it start from end then you can use like this:
textBox1.SelectionStart = textBox1.TextLength;
Hope it can help you.Have a nice day.
Bob Shen [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Monday, October 17, 2011 8:12 AM
All replies
-
-
Set the RightToLeft property of the textbox to true. But be sure that you text box contains RTL language characters like Arabic, then only it will make sense.
If you are developing a multicultured application, you can take support of inbuilt feature called localization
Friday, October 14, 2011 9:57 AM -
Actually i have the following code for creating the textbox with right to left alignment
Textbox txt1 = new Textbox();
txt.righttoleft = system.windows.forms.righttoleft.yes;
but i need multiline so i added the following code
txt1.Multiline = true;
now the cursor is positioned at the top right corner of the multiline text box.............
but i need bottom right of the cursor position..............
Friday, October 14, 2011 10:04 AM -
Actually i have the following code for creating the textbox with right to left alignment
Textbox txt1 = new Textbox();
txt.righttoleft = system.windows.forms.righttoleft.yes;
but i need multiline so i added the following code
txt1.Multiline = true;
now the cursor is positioned at the top right corner of the multiline text box.............
Friday, October 14, 2011 10:05 AM -
There's no built-in way for you to set that AFAIK, but you can implement the behavior yourself.
First, add an event handler on KeyPress event in your form's constructor:
this.textBox1.KeyPress += new KeyPressEventHandler(textBox1_KeyPress);
And then implement the following:
void textBox1_KeyPress(object sender, KeyPressEventArgs e) { this.textBox1.Select(0, 0); }
This will place the cursor at the side of latest entered charactor.
How to handle delete and backspace is left for you to implement.
Friday, October 14, 2011 10:08 AMAnswerer -
why you need the cursor at the bottom ? it should start writing from top. right ?
Thanks, Nishanth Mohan
Visit Places in LONDON for FREE!!!
A large collection of English / Hindi / Malayalam / Tamil SMS Messages
A large collection of English / Hindi / Malayalam / Tamil SMS MessagesFriday, October 14, 2011 10:10 AM -
Maybe possible for the TextBox in WPF form in the future (seems not implemented in current version so no effect).
There's no such support in Win32 edit control, so you'll have to create your own if you really need this kind of function.
Friday, October 14, 2011 10:22 AMAnswerer -
Hi srieja,
Welcome to the MSDN forum.
As far as I know you can realize right to left by
property. But if you want to start from textBox's bottom,
it is hard to realize(you need to realize a new control).
If you want to show a textfile in a textbox and hope
it start from end then you can use like this:
textBox1.SelectionStart = textBox1.TextLength;
Hope it can help you.Have a nice day.
Bob Shen [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Monday, October 17, 2011 8:12 AM