本文介绍了如何在ListView中对齐列的内容。 VB.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 你好! 请帮帮我,我不知道如何在ListView中对齐列的内容..我可以对齐ColumnHeader但是我不知道如何对齐其内容.. 请帮助Hello there!Please help me I don;t know how to align the contents of a column in my ListView.. I can align the ColumnHeader but I dont know how to align its contents..Please Help推荐答案' Aligns the content of column header to centerMe.listView1.ColumnFormatStyle.HeaderTextAlign = ContentAlignment.MiddleCenter' Aligns the content of column body to centerMe.listView1.ColumnFormatStyle.ContentAlign = HorizontalAlignment.Center' Aligns the content of column footer to rightMe.listView1.ColumnFormatStyle.FooterTextAlign = ContentAlignment.MiddleRight 但是,如果我们想要将特定列与其他列分开对齐,首先我们必须将StyleFromParent属性设置为false(以覆盖默认设置)。之后我们可以使用FormatStyle属性,该属性具有相同的字段,分别用于标题,正文和页脚的对齐。在这种情况下,代码将是:However, if we want to align a specific column separately from other columns, at first we must set the StyleFromParent property to false (to override the default settings). After that we can use the FormatStyle property which has the same fields for alignment of header, body and footer separately. In this case the code will be:' Override default settingscolumn.StyleFromParent = false;' Aligns the content of this column header to centercolumn.FormatStyle.HeaderTextAlign = ContentAlignment.MiddleCenter' Aligns the content of this column body to centercolumn.FormatStyle.ContentAlign = HorizontalAlignment.Center' Aligns the content of this column footer to rightcolumn.FormatStyle.FooterTextAlign = ContentAlignment.MiddleRight SubItems的水平对齐 默认情况下,所有子项都会继承其内容与其父列设置的对齐方式。为了与每个子项分别设置每个子项的对齐方式,就像列一样,我们首先需要将StyleFromParent属性设置为false,然后更改默认对齐方式:Horizontal Alignment of SubItemsAll subitems by default inherit the alignment of its content from their parent column settings. In order to set alignment for each subitem separately from other subitems, just like for columns, we at first need to set StyleFromParent property to false, and then change the default alignment: Aligns the text of this subitem to centersubItem.FormatStyle.TextAlign = ContentAlignment.MiddleCenter 从这里 [ ^ ] -KRRipped from here[^]-KR 这篇关于如何在ListView中对齐列的内容。 VB.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-31 01:06