I adapted this code from another thread in order to format my column widths. Now what my datagrid is doing is showing NOTHING, no rows, no columns, splat. I am posting the code in the hopes someone can tell me what I am doing wrong...
Visual Basic:
Dim ds As DataSet = New DataSet
drRead.Fill(ds, sptable)
With Me.dgFile
.DataSource = ds.Tables(sptable)
.CaptionText = sptable & " Table"
.Visible = True
If sptable = "Report_tbl" Then
.Width = 704
Else
.Width = 560
End If
.PreferredColumnWidth = 75
End With
Dim dgts1 As New DataGridTableStyle
With dgts1
.MappingName = sptable
End With
Dim grdColumn1 As New DataGridTextBoxColumn
With grdColumn1
.Width = 500
End With
Dim grdColumn2 As New DataGridTextBoxColumn
With grdColumn2
.Width = 2000
End With
Dim grdColumn3 As New DataGridTextBoxColumn
With grdColumn3
.Width = 800
End With
Dim grdColumn4 As New DataGridTextBoxColumn
With grdColumn4
.Width = 800
End With
Dim grdColumn5 As New DataGridTextBoxColumn
With grdColumn5
.Width = 800
End With
Dim grdColumn6 As New DataGridTextBoxColumn
With grdColumn6
.Width = 800
End With
Dim grdColumn7 As New DataGridTextBoxColumn
With grdColumn6
.Width = 800
End With
Dim cols() As DataGridColumnStyle = {grdColumn1, grdColumn2, grdColumn3, grdColumn4, grdColumn5, grdColumn6, grdColumn7}
dgts1.GridColumnStyles.AddRange(cols)
dgFile.TableStyles.Add(dgts1)
Me.dgFile.Show()
Last edited by a moderator: