C#-ListView列的文本大小在每台计算机上都不相同 [英] C# - ListView Column text size is not the same on each computer

查看:45
本文介绍了C#-ListView列的文本大小在每台计算机上都不相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用列表视图制作一个C#程序,并且在PC和上网本中,列的大小是完美的,但是当我在朋友计算机上运行该程序时,列的大小似乎变小了,例如,文本被剪切了. ,如果我的列在PC上显示"Hello Stackoverflow",则在朋友的PC上显示"Hello Stac ...".列大小是在代码中设置的,他没有调整大小...这怎么可能?我们使用的是相同的屏幕分辨率(1080p),即使他将分辨率更改为更大的分辨率(800x600),列文本仍然会被剪切掉,只是窗口通常更大...可能是默认字体窗户使所有这些问题? 谢谢大家!

I am making a C# program with a listview and in my PC and netbook the columns sizes are perfect, but when I run the program in my friends computer the column's size appear to be smaller, the text is being cut, for example, if my column shows "Hello Stackoverflow" in my PC, in my friend's PC it shows "Hello Stac..." . The column size is set in the code, and he is not resizing...how may this be possible? We are using the same screen resoluiton (1080p), and even if he changes the resolution to something bigger (800x600), the column text is still cut out, just the window in general is bigger...may it be a default font from windows making all this problem?? Thank you all!!

推荐答案

这可能与DPI设置有关.您的朋友可能启用了大字体".设置固定的列宽,您需要考虑DPI设置. 100像素始终是100像素,但是更改DPI设置会使朋友计算机上的8pt字体比您的朋友计算机上的字体大.

This may be a matter of the DPI setting. Your friend may have "large fonts" enabled. Setting fixed column widths, you need to take the DPI setting into account. 100 pixels are always 100 pixels, but changing the DPI setting makes 8pt font be larger on your friends machine than on yours.

您可以轻松地计算出这一点:

You can easily compute this:

int columnWidth = Desired Width / 96.0 * DPI;

,其中Desired Width是您希望列变宽的像素数,而DPI是当前计算机的水平DPI.

with Desired Width being the number of pixels you want the column to be wide and DPI being the horizontal DPI of the current machine.

这篇关于C#-ListView列的文本大小在每台计算机上都不相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆