Solved

Winforms datagrid - using one tablestyle for multiple grids

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AutoHotkey ActiveX Component Error 8 72
Get list of word ducuments in a folder 10 36
Getting multiple values from a dataset ASP.NET(VB) 3 37
VS.net 2010 11 23
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…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

920 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

14 Experts available now in Live!

Get 1:1 Help Now