I have a number of datagrids bound to collections. When the collections are
populated i get the column headings as per the ColumnStyles for the grid.
However if the collection is empty no column headings are visible.

Is there a way to force the headings to display other than having a dummy
item in the collection?

guy

Re: DataGrid Column Headers by Sijin

Sijin
Wed Sep 29 11:48:20 CDT 2004

Yes, implement a strongly typed indexer for the collection. Ofcourse
this won't work with built-in collections but only with custom collections.

For e.g. if your collection is of class Employee then you need to write
an indexer like this

public class EmployeeCollection : CollectionBase
{
public Employee this[int index]
{
get{ return List[index]; }
}
}

that's it..

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph


guy wrote:
> I have a number of datagrids bound to collections. When the collections are
> populated i get the column headings as per the ColumnStyles for the grid.
> However if the collection is empty no column headings are visible.
>
> Is there a way to force the headings to display other than having a dummy
> item in the collection?
>
> guy

Re: DataGrid Column Headers by guy

guy
Thu Sep 30 04:40:07 CDT 2004

many thanks:-)

guy

"Sijin Joseph" wrote:

> Yes, implement a strongly typed indexer for the collection. Ofcourse
> this won't work with built-in collections but only with custom collections.
>
> For e.g. if your collection is of class Employee then you need to write
> an indexer like this
>
> public class EmployeeCollection : CollectionBase
> {
> public Employee this[int index]
> {
> get{ return List[index]; }
> }
> }
>
> that's it..
>
> Sijin Joseph
> http://www.indiangeek.net
> http://weblogs.asp.net/sjoseph
>
>
> guy wrote:
> > I have a number of datagrids bound to collections. When the collections are
> > populated i get the column headings as per the ColumnStyles for the grid.
> > However if the collection is empty no column headings are visible.
> >
> > Is there a way to force the headings to display other than having a dummy
> > item in the collection?
> >
> > guy
>