Named columns in DataGridView in .NET?

SoftwareEng

Senior member
Apr 24, 2005
553
4
81
Hi Guys,

Is there a way to have named columns in the DataGridView control in .NET 2.0? So instead of saying,

grdMyGrid.Cells("AccountNumber") and grdMyGrid.Cells("Year"),

I'd say:

grdMyGrid.AccountNumber and grdMyGrid.Year

so it would resolve at design time and avoid run-time errors? So I'm looking to set up a property to match the name of my coilumn.

Big thanks.
 

MmmSkyscraper

Diamond Member
Jul 6, 2004
9,472
1
76
My friend (who knows .NET better than me) said you'd need to use reflection and create a collection which redefines the columns in the datagrid. He doesn't think it's worth the effort though.
 

SoftwareEng

Senior member
Apr 24, 2005
553
4
81
Originally posted by: MmmSkyscraper
My friend (who knows .NET better than me) said you'd need to use reflection and create a collection which redefines the columns in the datagrid. He doesn't think it's worth the effort though.

thanks for finding out. Too bad there's no built-in support for this...