How To Hide ListView ColumnHeader?
You can set the HeaderStyle
member of the ListView
to None
.
listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
Checkout the ListView HeaderStyle property. It has the following options:
- None
- Nonclickable
- Clickable
From MSDN:
The HeaderStyle property allows you to specify whether the column headers are visible or, if they are visible, whether they will function as clickable buttons. If the HeaderStyle property is set to ColumnHeaderStyle.None, the column headers are not displayed, although the items and subitems of the ListView control are still arranged in columns
You can also create simple object like ListItem
which has two poperties: Text
(string) and Tag
(object). Then implement ListItem.ToString() and you can use these in the ListBox
as well.
You can also check out Better ListView Express component, which is free and allows displaying items in Details view without columns. The advantage over ListBox and ListView is a native look and many extra features.
Easy way is using the ColumnWidthChanging
event
private void listViewExtended1_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
{
if (e.ColumnIndex == 0)
{
e.Cancel = true;
e.NewWidth = listViewExtended1.Columns[e.ColumnIndex].Width;
}
}