如何隐藏ListView控件中的列? [英] How to hide a column in a ListView control?
问题描述
如何在ListView
控件中隐藏列,而不将列Width
属性设置为0
?
How can I hide a column in a ListView
control, without setting the column Width
property to 0
?
还可以锁定列的Width
吗?
推荐答案
对于C++Cli
标记,这里不是很清楚,但是:
Not very clear what matters here C++Cli
tag, but:
我假设,如果您要谈论的是ListView
中的列,那么您将进入控件的详细信息视图.据我所知,在ListView
中没有内置的隐藏/显示"列方式,因此解决方案之一就是仅从UI中删除该列.
I presume that if you're talking about a columns in ListView
, you're in details view of the control. There is no builtin Hide/Show column way in ListView
, as much as I'm aware of, so one of solutions can be just remove that column form UI.
要尽可能以最流畅的方式进行操作,只需在
To do that in most smooth way possible just call your ListView
column regeneration code in between
listView.SuspendLayout(true);
/*Manipulate column here*/
listView.ResumeLayout();
在ListView
上可见的数据始终保持在您的手中,因此此刻您将决定再次显示该列,只需显示该列并再次填充ListView
.
The data which is visible on ListView
always remains "in your hands", so at the moment you will decide to show the column again, just show the column and fill ListView
again.
希望这会有所帮助.
这篇关于如何隐藏ListView控件中的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!