Solved

Winforms datagrid - using one tablestyle for multiple grids

Posted on 2004-09-28
3
339 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 125 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

813 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now