向从右到左的 ListView 项添加图标会导致图标在 C# WinForms 中翻转 [英] Adding an icon to right-to-left ListView items causes the icons to flip in C# WinForms
问题描述
我有一个 ListView
.其 RightToLeft
属性设置为是
,其 RightToLeftLayout
设置为 True
.ListView
用目录中的文件填充.
I have a ListView
. Its RightToLeft
property is set to Yes
and its RightToLeftLayout
is set to True
. The ListView
is populated with files in a directory.
在我的代码中,我使用 System.Drawing.Icon.ExtractAssociatedIcon(string filePath)
获得文件的相应图标,并将其分配给该文件.这意味着图标直接来自操作系统.我没有带有自定义图标的目录.
In my code, I get the appropriate icon of a file using System.Drawing.Icon.ExtractAssociatedIcon(string filePath)
and assign it to the file. This means that the icon come directly from the operating system. I do not have a directory with custom icons.
所以结果是这样的:
如您所见,PowerPoint文件图标被翻转.当我将布局更改为 LeftToRight
时,它可以完美显示.我该如何解决?
As you can see, the PowerPoint file icon is flipped. When I change the layout to LeftToRight
it is shown perfectly. How can I fix it?
谢谢.
推荐答案
如果只需要反转图标,建议将其放入 Bitmap
中,然后使用 Bitmap.RotateFlip
您可以将其水平翻转.
If you only need the icon to be reversed, I suggest putting it into a Bitmap
then using the Bitmap.RotateFlip
you can flip it horizontally.
Bitmap bm = System.Drawing.Icon.ExtractAssociatedIcon(string filePath).ToBitmap();
bm.RotateFlip(RotateFlipType.RotateNoneFlipX);
这篇关于向从右到左的 ListView 项添加图标会导致图标在 C# WinForms 中翻转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!