Quote:
quote:Originally posted by Kokeb
// Hide fifth column of m_listView
m_listView.Columns[4].Width = 0;
|
Setting the column width to 0 will appear to work, but the user can resize the column, which will reveal it again. Another way to hide it is to use the Add() and Remove() methods on the Gridview.Columns collection. This does not delete the columns. First, in your XAML code, give the GridView and GridViewColumn names:
<GridView x:Name="gv">
<GridViewColumn x:Name="gvc"...
Create a function like this to hide a column of your choice:
'Hide column
Private Sub HideColumn(ByVal Column As GridViewColumn)
If gv.Columns.Contains(Column) = True Then
'Remove column
gv.Columns.Remove(Column)
End If
End Sub
Now you can hide the column gvc using:
HideColumn(gvc)
Unhiding a column is similar. Just check if it is not in the list with "gv.Columns.Contains(Column) = False" and unhide it by using "gv.Columns.Add(Column)".
'Show column
Private Sub ShowColumn(ByVal Column As GridViewColumn)
If gv.Columns.Contains(Column) = False Then
'Add column
gv.Columns.Add(Column)
End If
End Sub