Is it possible to reapply a form-based tablestyle for a datagrid?

  • Thread starter Thread starter Mac via DotNetMonster.com
  • Start date Start date
M

Mac via DotNetMonster.com

Hi all,

I have a datagrid on a form which I have set the datasource (through the form
designer) to be a dataset that I have added to the form, also through the
form designer. I then have added a tablestyle which is mapped to the relevant
table in the dataset that is associated to the datagrid and I get pre-drawn
column headings for my datagrid.

Problem is I am losing these headings when I bind data to the datagrid from
another source (as part of a button click event). The reason this happens is
I have my own user class that inherits from the CollectionBase. I then bind
this user class to my datagrid and the public properties within my user class
appear on the datagrid as the headings thus overwritting the pre-drawn
headings.

What I would like to achieve is to reapply the tablestyle that I had setup
for the datagrid in the form designer orginally. Is this possible?

Is there an alternative way to achieve what I want while keeping my user
class ?

Any help is appreciated.


regards,

Mac
 
Hi,

Use Collection for the tablestyle's mapping name when you bind
the grid to an collection. Use Arraylist for the mapping name when you bind
to an arraylist. I would try the Name of your user class for the mapping
name

Ken
--------------

Hi all,

I have a datagrid on a form which I have set the datasource (through the
form
designer) to be a dataset that I have added to the form, also through the
form designer. I then have added a tablestyle which is mapped to the
relevant
table in the dataset that is associated to the datagrid and I get pre-drawn
column headings for my datagrid.

Problem is I am losing these headings when I bind data to the datagrid from
another source (as part of a button click event). The reason this happens is
I have my own user class that inherits from the CollectionBase. I then bind
this user class to my datagrid and the public properties within my user
class
appear on the datagrid as the headings thus overwritting the pre-drawn
headings.

What I would like to achieve is to reapply the tablestyle that I had setup
for the datagrid in the form designer orginally. Is this possible?

Is there an alternative way to achieve what I want while keeping my user
class ?

Any help is appreciated.


regards,

Mac
 
Hi Ken,

Thank you for your suggestion. I am a bit confused as to what to actually do.
Are you able to provide me with a code snippet?

I assume what I have to do is after I populate the datagrid, I need to
reapply the tablestyle. But in looking at the attributes for the datagrid and
the further sub-attributes for the tablestyles there is none to actually set
the tablestyle only to add a new tablestyle.

Is there a way to actually add a tablestyle that alredy exists in the
collection?

regards,

Mac
 
Back
Top