Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2004

Tip: Looking for answers? Try searching our database.

DataGrid Column Headers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
guy - 29 Sep 2004 17:33 GMT
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
Sijin Joseph - 29 Sep 2004 17:48 GMT
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

> 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.
[quoted text clipped - 4 lines]
>
> guy
guy - 30 Sep 2004 10:40 GMT
many thanks:-)

guy

> Yes, implement a strongly typed indexer for the collection. Ofcourse
> this won't work with built-in collections but only with custom collections.
[quoted text clipped - 24 lines]
> >
> > guy

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.