Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ListView ColumnHeader.Name is empty string

Tags:

c#

listview

I've created a WinForms ListView as Detail view with four columns. I've given each column a name in the designer, however when accessing each ColumnHeader via the ListView.Columns property, I find each ColumnHeader.Name is an empty string. Am I doing something wrong or is this a framework bug?

like image 887
Neil Barnwell Avatar asked Nov 07 '10 23:11

Neil Barnwell


1 Answers

I'm able to recreate the same behaviour. I think it must definitely be a bug as it's implied that the value will be set correctly by the designer.

As a workaround, you could put the name into the Tag property too. (Or set it programmatically in the constructor, but that won't work well if you need to add a column in the designer later on. I would then rather go with not using the designer at all to initialize the columns.)

I found some discussion on this here - looks like this is a known issue, they are also going with the Tag hack.

like image 183
steinar Avatar answered Oct 22 '22 07:10

steinar