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.

[699 byte] By [MarkWarner] at [2008-1-10]
# 1
I don't think you can hide a column on a ListView, you either have to remove it or set the .Width = 0. If the headings allow user-resizing then the 0 Width option is problematic as well.
Richard_Wolf at 2007-10-3 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 2

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.Click

ListView1.Columns.Add(oCol)

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim oItem As ListViewItem

oItem = ListView1.Items.Add("item here")

oItem.SubItems.Add("sub item")

End Sub

End Class

geoff.appleby at 2007-10-3 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 3
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.
MarkWarner at 2007-10-3 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 4
What about if you want to group item by a coumn that you don't want to show?
Chardiot at 2007-10-3 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 5

Hi!

Did you find a solution to this? I have the exact same question and apparantly no solution :-(

Thank you in advance

Kai Fransson

KaiFransson at 2007-10-3 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 6
Hi Mark,

just set columns width property to 0 means it will not show in listView but you can access it by using its index.
e.g.MenuListView.Columns[0].Width = 0; Where MenuListView is my ListView's object.

njoy!!

happy Programming!!!

Regards,
KIRAN PATIL
KiranPatil at 2007-10-3 > top of Msdn Tech,Visual Basic,Visual Basic Language...