[英]TextBox RTL with letters and numbers
I set the TextBox.RightToLeft
property to Yes
. 我将TextBox.RightToLeft
属性设置为Yes
。
When I'm entering this text: "a 32" the string that is stored is "32 a". 当我输入以下文本时:“ a 32”,存储的字符串为“ 32 a”。 the order of entering the text is: first 3 2 then Space and then a . 输入文本的顺序是:首先3 2然后是空格 ,然后是 。
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. 如果在运行时更改RightToLeft属性的值,则仅保留未格式化的原始文本。
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. 设置您的TextBox属性RightToLeft = NO并使用TextAlign = Right。
OP: How can I have the value stored as entered? OP:如何将输入的值存储起来?
The string will be stored exactly in the same order you entered characters regardless of display settings of TextBox
. 不管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. 如果输入3 2 Space a,则您的值将以相同的顺序存储,并且TextBox
的Text
属性的值将为32 a
而根据RightToLeft
和TextAlign
属性,其显示的值将有所不同。
Here is the result of entering the text in the order: 3 2 Space a . 这是按顺序输入文本的结果: 3 2 隔开 a 。 Choose your desired setting, store the string and then show it again in a TextBox
with the same settings. 选择所需的设置,存储字符串,然后在具有相同设置的TextBox
再次显示它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.