Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Winforms datagrid - using one tablestyle for multiple grids

Posted on 2004-09-28
3
Medium Priority
?
348 Views
Last Modified: 2010-07-27
Hi,

I have a windows form containing multiple DataGrids. I want to be able to apply the same DataGridTableStyle to 3 of the DataGrids on my form but do not want to create a DataGridTableStyle via the Visual Studio .NET form designer for each one.

I have added the DataGridTableStyle to each DataGrid's TableStyles collection, but this does not seem to apply the style.

There is a "DataGrid" property for the DataGridTableStyle, but this can only be set to one particular DataGrid.

I have also tried creating individual DataGridTableStyle objects for each DataGrid and adding the same GridColumnStyles objects to each, but this has not worked either.

Any suggestions?

Thanks!
0
Comment
Question by:quickly_james
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 375 total points
ID: 12176692
U can do it via code like this. U can  have a public function which accepts the datagrid as parameter. U can then set the style
for that particular datagrid

Dim style as DataGridTableStyle

Public Function DatagridStyle(datagrid1 as DataGrid) as Boolean

      datagrid1 .TableStyles.Clear()

        style = Nothing
        style = New DataGridTableStyle
        datagrid1 .TableStyles.Add(style )
        style .MappingName = ""
        style .MappingName = dataTable.TableName
        style .GridColumnStyles.Clear()

// Continue with the modifications u want
End Function
0
 
LVL 10

Expert Comment

by:123654789987
ID: 12176695
0
 

Author Comment

by:quickly_james
ID: 12187324
Thanks for your help!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

916 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