I set the TextBox.RightToLeft
property to Yes
.
When I'm entering this text: "a 32" the string that is stored is "32 a". the order of entering the text is: first 3 2 then Space and then a .
How can I have the value stored as entered?
If the value of the RightToLeft property is changed at run time, only raw text without formatting is preserved.
You will have to reverse its order yourself:
string[] text = textBox1.Text.Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries); //get string while preserving the words
Array.Reverse(text); //reverse the order of words (not their chars)
string finalValue = string.Join(" ", text); //make the string out of array
Try this:
Set your TextBox Property RightToLeft = NO and use TextAlign = Right.
OP: How can I have the value stored as entered?
The string will be stored exactly in the same order you entered characters regardless of display settings of TextBox
.
If you enter 3 2 Space a then your values will be stored in the same order and the value of Text
property of TextBox
will be 32 a
while it will be displayed different based on RightToLeft
and TextAlign
property.
Here is the result of entering the text in the order: 3 2 Space a . Choose your desired setting, store the string and then show it again in a TextBox
with the same settings.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.