Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
900
Binding the Grid to a Generic List and displaying Custom Headers
posted

Hi,

I want to display a generic list of "Person" objects in an ultragrid.

My "Person" object contains properties for Name, Birthday, Address, and IsMarried.

I am able to set the Ultragrid's DataSource to a Generic List of Person objects.  My problem is that the column headers are just the Property names.  I'd like to be able to customize these names - for instance, IsMarried should really be shown to the user with a space in the name - "Is Married".

Is there some sort of attribute that i need to add to the properties, or another way of customizing these headers?

Thanks for the help,

~Karen

Parents
  • 900
    posted

    I think I have partially found an answer...

    If I import System.ComponentModel, I can then add a DisplayName attribute to my properties.  For example,

     

    <DisplayName("Is Married")> _
    Public Property IsMarried() As Boolean
    .....
    E
    nd Property

    Now I have a new question.  I want to add a Hobbies collection (Generic List of Strings) to my Person object.  When I do this, I get a second band added to my grid like i would expect, however, the header is labeled "Values".  Setting the DisplayName attribute on the Hobbies collection didn't work, I'm guessing because it's really the data inside of the collection that's being displayed.  Could someone tell me how to get a custom header on this field?

    Thanks,

    ~Karen

     

Reply Children