为什么我的列表视图框中的项目都挤在一起?

huangapple go评论84阅读模式
英文:

Why are the items in my listview box all cramped together?

问题

我只是试图在Microsoft Visual Studio的列表视图框中显示一些数据,但每当我这样做时,所有的数据都会混在一起,排列紧凑。当我尝试使用小字体和大字体时,结果都一样,我不确定如何确切地修复它。

这是我使用的显示代码:

lvwPayroll.Items.Add("薪酬员工总数: " + salariedEmployees);
lvwPayroll.Items.Add("薪酬员工的年薪总额");
//添加更多
lvwPayroll.Items.Add("---------------------------------------------");
lvwPayroll.Items.Add("时薪员工总数: " + wagedEmployees);
lvwPayroll.Items.Add("时薪员工的年薪总额");
//添加更多
lvwPayroll.Items.Add("---------------------------------------------");
lvwPayroll.Items.Add("---------------------------------------------");

而这是最终的显示效果:

为什么我的列表视图框中的项目都挤在一起?

有人知道为什么会发生这种情况或如何修复吗?

英文:

I'm just trying to display some data in a listview box on Microsoft Visual Studio but whenever I do it's all jumbled together and cramped up. When I did small and big font it was the same result and I'm not sure how exactly to fix it.

This is the display code that I have:

lvwPayroll.Items.Add("Total Number of Salaried Employees: " + salariedEmployees);
lvwPayroll.Items.Add("Total Annual Pay for Salaried Employees");
//ADD MORE
lvwPayroll.Items.Add("---------------------------------------------");
lvwPayroll.Items.Add("Total Number of Waged Employees: " + wagedEmployees);
lvwPayroll.Items.Add("Total Annual Pay for Waged Employees");
//ADD MORE
lvwPayroll.Items.Add("---------------------------------------------");
lvwPayroll.Items.Add("---------------------------------------------");

and this is what it turns out to be:

为什么我的列表视图框中的项目都挤在一起?

Does anyone know why this is happening or how to fix it?

答案1

得分: 2

我同意LarsTech的评论。话虽如此,是的,我相信我知道为什么会发生这种情况以及如何修复它。除非你在表单设计师中更改它,否则lvwPayroll.View的默认值可能是LargeIcon。你看到的可能是7个_图标_的渲染(每个Item一个),它们_没有_图像,但_确实_具有一个非常长的标题,被挤压到图标矩形的狭窄宽度中。

尝试将View属性设置为List

lvwPayroll.View = View.List;

lvwPayroll.Items.Add("薪资员工总数: " + salariedEmployees);
lvwPayroll.Items.Add("薪资员工年薪总额");
//添加更多
lvwPayroll.Items.Add("---------------------------------------------");
lvwPayroll.Items.Add("计件员工总数: " + wagedEmployees);
lvwPayroll.Items.Add("计件员工年薪总额");
//添加更多
lvwPayroll.Items.Add("---------------------------------------------");
lvwPayroll.Items.Add("---------------------------------------------");

为什么我的列表视图框中的项目都挤在一起?

英文:

I agree with the comment by LarsTech. That said, yes I believe I do "know why this is happening and how to fix it". Unless you change it in the form designer, the default value for lvwPayroll.View is probably LargeIcon. What you are seeing is likely a rendering of 7 icons (one for each Item) that don't have an image, but do have a very long title that's being squashed into the narrow width of the icon's rectangle.


Try setting the View property to List.

lvwPayroll.View = View.List;

lvwPayroll.Items.Add("Total Number of Salaried Employees: " + salariedEmployees);
lvwPayroll.Items.Add("Total Annual Pay for Salaried Employees");
//ADD MORE
lvwPayroll.Items.Add("---------------------------------------------");
lvwPayroll.Items.Add("Total Number of Waged Employees: " + wagedEmployees);
lvwPayroll.Items.Add("Total Annual Pay for Waged Employees");
//ADD MORE
lvwPayroll.Items.Add("---------------------------------------------");
lvwPayroll.Items.Add("---------------------------------------------");

为什么我的列表视图框中的项目都挤在一起?

huangapple
  • 本文由 发表于 2023年3月3日 23:27:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75628973.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定