C# ListView and RightToLeft

本小妞迷上赌 提交于 2019-12-24 10:15:00

问题


I need to view english text in a listview with the RightToLeft property set to "true".
When I put brackets in the text it seems to be reversed.
If I try to write "Stack(Overflow)" I will see "(Stack(Overflow".
Is there a way to fix this?

this is a part of my code:

                    Item = (ListViewItem) myList.Items.Add(id, myString, iconIndex);
                    MyListView.SetSubItemText(Item, 1, s1);
                    MyListView.SetSubItemText(Item, 2, s2);
                    MyListView.SetSubItemText(Item, 3, s3);
                    MyListView.SetSubItemText(Item, 4, s4);

回答1:


This strongly depends on the version of Windows you use, list view is implemented as a native control in Windows, the ListView class is only a managed wrapper for it. The right-to-left rendering behavior has changed across different versions.

In general, you should only ever set RightToLeft to Yes when you localized your user interface to a language that requires right-to-left rendering of text. Hebrew or Arabic. Getting unusual behavior with strings in another language is not unexpected. If your intent was to get different alignment using that property then you'll have to find an alternative. Like OwnerDraw or ColumnHeader.TextAlign



来源:https://stackoverflow.com/questions/7103798/c-sharp-listview-and-righttoleft

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!