How does one hide a ListView column?
Is it possible to hide a listview column? I don't want to remove it, and I want to process the data in it. I just want to hide it. The problem is that the column will contain potentially sensitive information, and I want to be able to protect against shoulder surfers.
The problem is, I cannot find aListView.Columns(n).Hide()method or aListView.Columns(n).Visible property.
Is this possible to do, or do I just have to remove the column? It doesn't seem like it should be all that hard.
Thanks,
Mark Warner.
As said before, you can't hide, but you can remove.
But removing isn't so bad, if you keep a handle on it. When you take a column out, if you keep a reference to that column, you can add it back in again.
For example, here's some dodgy I wrote that hides and then adds back in a column :)
Public Class Form1
Dim oCol As ColumnHeader
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
oCol = ListView1.Columns.Item(0)
ListView1.Columns.Remove(oCol)
End Sub
Private
Sub
Button2_Click(ByVal
sender As
System.Object, ByVal
e As
System.EventArgs) Handles
Button2.ClickListView1.Columns.Add(oCol)
End
Sub
Private
Sub
Form1_Load(ByVal
sender As
System.Object, ByVal
e As
System.EventArgs) Handles
MyBase
.LoadDim
oItem As
ListViewItem oItem = ListView1.Items.Add(
"item here")oItem.SubItems.Add(
"sub item") End
Sub
End Class
Well, I got this working, but it was a little confusing for one of my users, so I went another direction. Instead of simply removing the column, I put "(hidden)" in the first row of the hidden column, and ". . ." in the rest of the rows. This seems to be a little more intuitive.