Solved

Winforms datagrid - using one tablestyle for multiple grids

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

16 Experts available now in Live!

Get 1:1 Help Now