Q: DataGrid

G

Geoff Jones

Hi

It is possible to associate several TableStyles with one DataGrid e.g.

Dim tableStyle1 As New DataGridTableStyle
Dim tableStyle2 As New DataGridTableStyle

DataGrid1.TableStyle.Add(tableStyle1)
DataGrid1.TableStyle.Add(tableStyle2)

When the grid is displayed, will it be the first Table Style that is used?
Also, how do I get the DataGrid to display the other table style?

Thanks in advance

Geoff
 
G

Guest

According to DataGridTableStyle.MappingName will automatically pickup a
DataGridTableStyle. For Example:

dim Tb1 as new dataTable("Name1")
....
dim Tb2 as new dataTable("Name2")
....

Dim tableStyle1 As New DataGridTableStyle
tableStyle1.MappingName ="Name1"

Dim tableStyle2 As New DataGridTableStyle
tableStyle2.MappingName ="Name2"

DataGrid1.TableStyle.Add(tableStyle1)
DataGrid1.TableStyle.Add(tableStyle2)

DataGrid1.DataSource=Tb1 'Use tableStyle1
DataGrid2.DataSource=Tb2 'Use tableStyle2
 
G

Geoff Jones

Hi Rulin

I think you've misunderstood. If I'm adding different styles to the same
DataGrid e.g. DataGrid1, how do I dynamically switch from one style to
another in the code?

Geoff
 
G

Guest

Geoff,

Be flexible. Changing DataGridTableStyle.MappingName absolutely can meet
your requirement. For example:
Change style from tableStyle1 to tableStyle2

dataGrid1.datasource=nothing
tableStyle1.MappingName =""
tableStyle1.MappingName ="tableName"
dataGrid1.datasource=datatable
 
G

Geoff Jones

Ah, I see what you mean. Many thanks

Geoff

Rulin Hong said:
Geoff,

Be flexible. Changing DataGridTableStyle.MappingName absolutely can meet
your requirement. For example:
Change style from tableStyle1 to tableStyle2

dataGrid1.datasource=nothing
tableStyle1.MappingName =""
tableStyle1.MappingName ="tableName"
dataGrid1.datasource=datatable
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top