Displaying collection in a winform datagrid

M

Michael Kellogg

I have a collection of objects that I am trying to display in a Windows
Forms Datagrid. I have had problems doing this before, so the first time
around I went and did a Grid.TableStyles.Clear before naming my collection
as the DataSource.

In this scenario, the collection's members come up perfect in the datagrid,
but I have no control over the look of it. So I added a TableStyle and a
GridColumnStyle object in the designer, giving the names of my collection's
object's members as the MappingName property for each column. I left the
MappingName of the TableStyle blank. I also got rid of the
"TableStyles.Clear" line.

In short, nothing different happens. Everything loads in as though there
were no tablestyle defined. Can anyone tell me why, and how to make my
tablestyle appear?
 
C

Chris

Michael said:
I have a collection of objects that I am trying to display in a Windows
Forms Datagrid. I have had problems doing this before, so the first time
around I went and did a Grid.TableStyles.Clear before naming my collection
as the DataSource.

In this scenario, the collection's members come up perfect in the datagrid,
but I have no control over the look of it. So I added a TableStyle and a
GridColumnStyle object in the designer, giving the names of my collection's
object's members as the MappingName property for each column. I left the
MappingName of the TableStyle blank. I also got rid of the
"TableStyles.Clear" line.

In short, nothing different happens. Everything loads in as though there
were no tablestyle defined. Can anyone tell me why, and how to make my
tablestyle appear?

It's because it doesn't which tablestyle to use. You need to name the
tablestyle.mappingname to the name of your collection.

Chris
 
M

Michael Kellogg

Chris said:
It's because it doesn't which tablestyle to use. You need to name the
tablestyle.mappingname to the name of your collection.


Thanks for the pointer. I had messed with that earlier but couldn't get
anything to change. The name of my datasource was "m_doc.EntryPoints"; I
tried that name, and I'd tried "EntryPoints", neither of which had any
effect. I just now tried "Collection" and VOILA... Bizarre.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top