Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fixed! :) VB.NET datagrid
Message
From
14/12/2001 10:38:11
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Fixed! :) VB.NET datagrid
Miscellaneous
Thread ID:
00594415
Message ID:
00594415
Views:
56
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.
Reply
Map
View

Click here to load this message in the networking platform