I have a DataGridView, whose DataSource I am setting to a List<T>
. T
in this case is a class with a property called Foo
, whose header I want to show as Foo bar
.
If it was a datatable, I could just change the query:
select Foo as [Foo bar] from Baz
But with something like this, where I'm setting the DataGridView's DataSource to a List<Baz>
:
public class Baz {
public string Foo { get; set; }
}
I can't rename "Foo
" to "Foo bar
" because it contains spaces. Do I have to rename the DataGridViewColumn manually?
The most awesome thing would be if I could use class decorators, something like this:
public class Baz {
[DataGridViewColumnTitle("Foo bar")]
public string Foo { get; set; }
}
But I as far as I can see, nothing like that exists in the standard library.
What's my best option?