隐藏在ListView控件ID列 [英] Hide ID column in ListView control
本文介绍了隐藏在ListView控件ID列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我结合ListView控件数据表。该数据表中有一个名为ProductID列。有什么办法来隐藏此列,因为我会需要它的价值更高?
I'm binding ListView control to DataTable. The DataTable have a column named ProductID. Is there any way to hide this column, because I'm gonna need it's value later?
推荐答案
我就满足了用户界面的角度。您可以通过列的宽度设置为0。例如隐藏它,如果ID绑定到第2列:
I'll just address the UI angle. You can hide it by setting the column width to 0. For example, if the ID is bound to the 2nd column:
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
listView1.Columns[1].Width = 0;
listView1.ColumnWidthChanging += listView1_ColumnWidthChanging;
}
private void listView1_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e) {
if (e.ColumnIndex == 1) {
e.NewWidth = 0;
e.Cancel = true;
}
}
}
这不是很理想,用户可以通过分流光标,显示了她有点过头,将列分割的权利得到confuzzled。这是非常难以解决。
It's not quite ideal, the user can get confuzzled by the 'splitter' cursor that shows up when she's a bit too far to the right of the column divider. That's very hard to fix.
这篇关于隐藏在ListView控件ID列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文