Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Solution to VB.NET datagrid problem
Message
De
14/12/2001 10:55:52
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Titre:
Solution to VB.NET datagrid problem
Divers
Thread ID:
00594442
Message ID:
00594442
Vues:
69
Thanks for the help guys. I don't know why I had so much problems with this. At least I know of a bunch of ways on how NOT to create a customDataStyle. Anyway here is the solution and thanks again for the help. (You guys are the BEST!)

Create a CustomDataStyle procedure.
Run the procedure from the load event.

Everytime you requery your data - set
Datagrid.TableStyle(0).MappingName = ""
Datagrid.DataSource = ObjectDataSet
Datagrid.DataMember = "TableName"
Datagrid.TableStyle(0).MappingName = "TableName"
If you do not set the MappingName to "" before setting the DataSource you get an error. At least I did. Here is the CustomDataStyle procedure.

Private Sub CustomDataStyle()

Dim Ts1 as New DataGridTableStyle()
Ts1.MappingName = "Operator"

Dim grdColStyle as New DataGridTextBoxColumn()

grdColStyle.Width = 80
grdColStyle.MappingName = "Field1"
grdColStyle.HeaderText = "Field One"
Ts1.GridColumnStyles.Add(grdColStyle)

' Must set grdColStyle to New for every column, else every column uses the
' last column style that you set up
grdColStyle = New DataGridTextBoxColumn()
grdColStyle.Width = 80
grdColStyle.MappingName = "Field2"
grdColStyle.HeaderText = "Field Two"
Ts1.GridColumnStyles.Add(grdColStyle)

grdColStyle = New DataGridTextBoxColumn()
grdColStyle.Width = 80
grdColStyle.MappingName = "Field3"
grdColStyle.HeaderText = "Field Three"
Ts1.GridColumnStyles.Add(grdColStyle)

DataGrid.TableStyles.Add(Ts1)

End Sub
Randy Belcher
AFG Industries, Inc.
Répondre
Fil
Voir

Click here to load this message in the networking platform