Private Sub ShowOrderDetail(ByVal SalesHeaderID As Integer)
Dim sql As String = "spOrderDetail"
Dim ds As New DataSet
Dim grd As New DataGridView
Try
Using conn As New SqlConnection(My.Settings.OrderEntrySalesConnectionString)
conn.Open()
Using da As New SqlDataAdapter(sql, conn)
With da
.SelectCommand.CommandType = CommandType.StoredProcedure
.SelectCommand.Parameters.Add("@SalesHeaderID", SqlDbType.Int).Direction = ParameterDirection.Input
.SelectCommand.Parameters("@SalesHeaderID").Value = SalesHeaderID
.Fill(ds)
End With
End Using
End Using
Catch ex As Exception
DisplayErrorMsgLogToTable(ex, "Customer Browse - audit - 1")
End Try
Try
grd.Name = "grd"
grd.DataSource = ds.Tables(0)
grd.Size = New System.Drawing.Size(720, 220)
'
' ******************************
' Here comes the error if uncomment the following
' commented lines.
'
'grd.Columns(0).Width = 80
'grd.Columns("Description").Width = 200
'grd.Columns("By Wt.").Width = 45
'grd.Columns("Inventory").Width = 55
grd.Visible = True
grd.ScrollBars = ScrollBars.Vertical
grd.RowHeadersVisible = False
Dim frm As New Windows.Forms.Form
With frm
.Size = New System.Drawing.Size(730, 300)
.Controls.Add(grd)
.Dock = DockStyle.Fill
.BringToFront()
.StartPosition = FormStartPosition.CenterParent
.SizeGripStyle = Windows.Forms.SizeGripStyle.Hide
.Text = "Order Detail for " + Me.cboCustomerPickupSalesHeaderID.SelectedText.ToString
.MinimizeBox = False
.MaximizeBox = False
.ShowDialog()
.Dispose()
.Close()
End With
Catch ex As Exception
DisplayErrorMsgLogToTable(ex, "ShowOrderDetail")
End Try
End Sub
|