Solved

Duplicate Datagridtablestyle

Posted on 2007-11-16
12
187 Views
Last Modified: 2013-12-17
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???????
0
Comment
Question by:gvector1
  • 6
  • 6
12 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20299054
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
0
 

Author Comment

by:gvector1
ID: 20299198
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.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20299347
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:gvector1
ID: 20299407
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??????
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20300138
If they are "basically" the same, what is different?  Are you saying that you want to have one style for multiple grids?

Bob
0
 

Author Comment

by:gvector1
ID: 20312871
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.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20313607
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
0
 

Author Comment

by:gvector1
ID: 20316040
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
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20316600
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
0
 

Author Comment

by:gvector1
ID: 20316664
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.  
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 20320056
I was trying to describe this kind of method:

private void SetDataGridStyle(DataGridTableStyle style)
{
}

Create 2 separate instances of the DataGridTableStyle, and pass each one into the same method to get created:

private void InitializeDataGrids()
{
     DataGridTableStyle style1 = new DataGridTableStyle();
     DataGridTableStyle style2 = new DataGridTableStyle();

     this.SetDataGridStyle(style1);
     this.SetDataGridStyle(style2);
}

Bob
0
 

Author Closing Comment

by:gvector1
ID: 31495776
Thanks
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question