Problem with DataGrid1.TableStyles

J

Jerry Spence1

I have created some definitions at design time for a Datagrid. How do I
actually switch one of the definition on - ie make it active?

I've tried Datagrid1.TableStyles.Add - but that just adds it to the
collection. I feel I need something like:

Datagrid1.TableStyles(0).active = True

Also, having created a style and given it a name (Style1) how do I refer to
it?

Datagrid1.TableStyles(Style1).active = True ???

- Jerry
 
C

Cor Ligthert

Jerry,

I thought that this would be it.

\\\
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
For Each a As DataGridTableStyle In DataGrid1.TableStyles
a.MappingName = Nothing
Next
DataGrid1.TableStyles(1).MappingName = "Persons"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
For Each a As DataGridTableStyle In DataGrid1.TableStyles
a.MappingName = Nothing
Next
DataGrid1.TableStyles(2).MappingName = "Persons"
End Sub
///
And not set the Mappingname in advance

Personaly it looks for me easier just to remove constantly the first one
with
datagrid1.tablestyles.removeat(0)
and than replace it with a new one again with Add

I hope this helps?

Cor
 
J

Jerry Spence1

Thanks for this. I have just found the answer elsewhere.A given style is
applied when the Datagrid's DataMember property is equal (in case as well)
to the DataGridTagleStyle's MappingName property.

- Jerry
 
C

Cor Ligthert

Jerry,

That is the same answer as I give you?

I give you as well the answer how to do that because your mappingname have
to be the same as your datasource member.

Cor
 

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