英文:
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("---------------------------------------------");
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论