''//It's not really a generalized safe thread datagridview, i just input the details to run safely.
''//This is a bad programming code style I know, but there's many way to kill a chicken.
''//begin cross threaded DataGridView component
Private Sub dBgRIDvIEWNotInvokeRequired(ByVal yselect As Integer, ByVal dBGridViewcomponentname As DataGridView, _
ByVal dvalue As Integer, ByVal yfilename As String, ByVal ypapersize As String, _
ByVal ynumpages As Integer, ByVal yimagecount As Integer, ByVal yregularprice As Decimal, ByVal ycountedimages As Integer)
If yselect = 1 Then
dBGridViewcomponentname.ColumnCount = 5
dBGridViewcomponentname.RowCount = dvalue
dBGridViewcomponentname.Update()
dBGridViewcomponentname.Columns(0).HeaderText = "PaperSize"
dBGridViewcomponentname.Columns(1).HeaderText = "Charge_Pages"
dBGridViewcomponentname.Columns(2).HeaderText = "#of_Images"
dBGridViewcomponentname.Columns(3).HeaderText = "Payable"
dBGridViewcomponentname.Columns(4).HeaderText = "CountedImage"
dBGridViewcomponentname.Update()
ElseIf yselect = 2 Then
dBGridViewcomponentname.Rows(dvalue).ErrorText = yfilename
dBGridViewcomponentname.Rows(dvalue).HeaderCell.Value = yfilename
dBGridViewcomponentname.Rows(dvalue).Cells(0).Value = ypapersize
dBGridViewcomponentname.Rows(dvalue).Cells(1).Value = ynumpages
dBGridViewcomponentname.Rows(dvalue).Cells(2).Value = yimagecount
dBGridViewcomponentname.Rows(dvalue).Cells(3).Value = yregularprice
dBGridViewcomponentname.Rows(dvalue).Cells(4).Value = ycountedimages
dBGridViewcomponentname.Update()
ElseIf yselect = 3 Then
dBGridViewcomponentname.Update()
ElseIf yselect = 4 Then
dBGridViewcomponentname.Rows.RemoveAt(dvalue)
End If
End Sub
Private Sub CrossThreadedDbGridView(ByVal yselect As Integer, ByVal dBGridViewcomponentname As DataGridView, _
ByVal dvalue As Integer, ByVal yfilename As String, ByVal ypapersize As String, _
ByVal ynumpages As Integer, ByVal yimagecount As Integer, ByVal yregularprice As Decimal, ByVal ycountedimages As Integer)
Try
If InvokeRequired Then
Dim udd As New deldBGrridView(AddressOf CrossThreadedDbGridView)
Invoke(udd, New Object() {yselect, dBGridViewcomponentname, dvalue, yfilename, ypapersize, ynumpages, yimagecount, yregularprice, ycountedimages})
Else
dBgRIDvIEWNotInvokeRequired(yselect, dBGridViewcomponentname, dvalue, yfilename, ypapersize, ynumpages, yimagecount, yregularprice, ycountedimages)
End If
Catch ex As Exception
End Try
End Sub
Private Delegate Sub deldBGrridView(ByVal yselect As Integer, ByVal dBGridViewcomponentname As DataGridView, _
ByVal dvalue As Integer, ByVal yfilename As String, ByVal ypapersize As String, _
ByVal ynumpages As Integer, ByVal yimagecount As Integer, ByVal yregularprice As Decimal, ByVal ycountedimages As Integer)
''//end cross threaded DataGridView component
''//usage:
CrossThreadedDbGridView(2, DbGridPapers, rc, FileName, xpapersize, xpNumbers, xiNumbers, ((xRegularPrice * xpNumbers) + xTotImageCounts), xTotImageCounts)