Link to home
Start Free TrialLog in
Avatar of gvector1
gvector1

asked on

Duplicate Datagridtablestyle

I am wondering if there is any way to duplicate a DataGridTableStyle as there are 2 datagrids that I would like to have the same type of display, just filtered differently.  Is there any way I can duplicate the dgtablestyle so I can add it to a seperate datagrid???????
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

What do you mean by "filtered" differently?  If you are talking about filtering the rows, then you should bind the DataGrid to a DataView with a RowFilter set to filter the records that you want to display, and not "duplicate" a style.

Bob
Avatar of gvector1
gvector1

ASKER

Yes, I will be using a different dataview for each table, but was also going to use a tablestyle to format how the data is presented.  Basically, 1 table with 2 views.  Each view shown in a separate datagrid that uses a tablestyle.
If you want to switch between different views, then you should create a different table style for each view, instead of copying an existing style.

Bob
That is kind of what I am asking.  The table styles will basically be the same.  I was wondering if there was a way to duplicate a tablestyle object into another tablestyle object so I can have the same formatting for 2 different datagrids???  Or would I have to manually declare another tablestyle like I did the first one??????
If they are "basically" the same, what is different?  Are you saying that you want to have one style for multiple grids?

Bob
I guess you could say that.  I would like to have the same style for 2 different grids that will display the same table, just filtered differently.  IE: One grid will list completed faxes, the other will list incomplete faxes.
Since it has been a long time for DataGrid and DataGridTableStyle, what is the problem with reusing the same style for 2 grids, with different DataView.RowFilter applied?

Bob
If I try to apply the same tablestyle to 2 different datagrids, I get the following error:

Cannot add a DataGridTableStyle already parented to another DataGrid
Ok, now I understand why you need the style copied.  How are you creating the style?  There isn't any Clone or Copy method, so it would be helpful if you had a method that you could pass in a reference to a DataGridTableStyle, and have the properties set for the column styles by the method.

Bob
That's what I was wondering.  I knew there was no visible Clone or Copy method for the TableStyle, so I was asking for alternative suggestions.  
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks