Solved

Winforms datagrid - using one tablestyle for multiple grids

Posted on 2004-09-28
3
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

617 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