C# ListView 和 RightToLeft
我需要在列表视图中查看英文文本,并将 RightToLeft 属性设置为“true”。
当我在文本中放入括号时,它似乎被颠倒了。
如果我尝试写“Stack(Overflow)”,我会看到“(Stack(Overflow”)。
有办法解决这个问题吗?
这是我的代码的一部分:
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);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这很大程度上取决于您使用的 Windows 版本,列表视图在 Windows 中作为本机控件实现,ListView 类只是它的托管包装器。从右到左的渲染行为在不同版本中发生了变化。
一般来说,只有当您将用户界面本地化为需要从右到左呈现文本的语言时,才应将 RightToLeft 设置为 Yes。希伯来语或阿拉伯语。使用另一种语言的字符串出现异常行为并不意外。如果您的目的是使用该属性获得不同的对齐方式,那么您必须找到替代方案。类似于 OwnerDraw 或 ColumnHeader.TextAlign
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