6

I have a C# ListView in mode "details", which makes the headers visible. I have 2 columns only, and still there's always a third junk empty one.

Anyone familiar with how to hide that ? I'm supposed to hand in a professional application and that's the kind of stuff that I'll get killed for GUI-wise..

Thanks ;)

BuZz
  • 14,398
  • 28
  • 80
  • 133

1 Answers1

6

That third one I believe is just the leftover space. You'll need to size the other columns to fit. See this posting: Adjust ListView columns to fit with WinForms

The key is the -2 on the last column:


[c#]
private void Form1_Load(object sender, System.EventArgs e)
{
    SizeLastColumn(lvSample);
}

private void listView1_Resize(object sender, System.EventArgs e)
{
    SizeLastColumn((ListView) sender);
}

private void SizeLastColumn(ListView lv)
{
    lv.Columns[lv.Columns.Count - 1].Width = -2;
}
Community
  • 1
  • 1
Adam Tuliper
  • 29,829
  • 4
  • 51
  • 70