Private Function BindDataSet(ByVal myWO As String, ByRef mDS As DataSet) As Boolean
Dim i As Integer = 0
mDS.Tables(0).DefaultView.RowFilter = "WO_Number = '" & myWO & "'"
If mDS.Tables(0).DefaultView.Count = 0 Then
Else
' we have rows to bind
mDS.Tables(1).DefaultView.RowFilter = "WO_Number = '" & myWO & "'"
For i = 0 To mDS.Tables(1).DefaultView.Count - 1
Dim myObj As New ListViewItem
Dim curRow As DataRow
curRow = mDS.Tables(1).Rows(i)
myObj.Text = mDS.Tables(1).Rows(i).Item(2).ToString
' myObj.SubItems.Add(mDS.Tables(1).DefaultView.Item(3).ToString)
myObj.SubItems.Add(mDS.Tables(1).Rows(i).Item(5).ToString)
myObj.SubItems.Add(mDS.Tables(1).Rows(i).Item(4).ToString)
If mDS.Tables(1).Rows(i).Item(6) = True Then
myObj.SubItems.Add("R")
myObj.ForeColor = Color.Red
lblResiCharges.Text = FormatCurrency(CDbl(lblResiCharges.Text) + (CDbl(mDS.Tables(1).Rows(i).Item(5).ToString)) * CDbl(mDS.Tables(1).Rows(i).Item(4).ToString))
Else
myObj.SubItems.Add("C")
End If
myObj.SubItems.Add(mDS.Tables(1).Rows(i).Item(1).ToString)
lblTotalCharges.Text = FormatCurrency(CDbl(lblTotalCharges.Text) + (CDbl(mDS.Tables(1).Rows(i).Item(5).ToString)) * CDbl(mDS.Tables(1).Rows(i).Item(4).ToString))
' myObj.Text =
ListView1.Items.Add(myObj)
Next
End If
End Function
Private Function FillListBox(ByVal mText As String, ByVal mTag As String, ByVal mQty As Integer, ByVal mResident As Boolean) As Boolean
Dim mPrice As String = SplitString(mTag, 1)
Dim mItemID As String = SplitString(mTag, 0)
mInspectionCost = mInspectionCost + (CDbl(mPrice))
Dim myGroup As String = TabInspection.SelectedTab.Text
Dim mCHG As String = ""
Dim myObj As New ListViewItem
Dim myRow As DataRow
myRow = dsInspectionsInv.Tables(1).NewRow
myRow.Item(0) = Trim(lblWONo.Text)
myRow.Item(1) = mItemID
myRow.Item(2) = Trim(myGroup)
lblTotalCharges.Text = FormatCurrency(CDbl(lblTotalCharges.Text) + (CDbl(mPrice) * CDbl(mQty)))
If mResident = True Then
mCHG = "R"
lblResiCharges.Text = FormatCurrency(CDbl(lblResiCharges.Text) + (CDbl(mPrice) * CDbl(mQty)))
' myRow.Cells. = Color.Red
Else
mCHG = "C"
End If
myRow.Item(3) = Trim(mText)
myRow.Item(4) = mQty
myRow.Item(5) = mPrice
myRow.Item(6) = mCHG
dsInspectionsInv.Tables(1).Rows.Add(myRow)
dsInspectionsInv.AcceptChanges()
lblTotalCharges.Text = FormatCurrency(lblTotalCharges.Text, 2)
lblResiCharges.Text = FormatCurrency(lblResiCharges.Text, 2)
If mResident = True Then
dgItems.Rows(dgItems.Rows.Count - 1).DefaultCellStyle.ForeColor = Color.Red
Else
End If
MsgBox(dsInspectionsInv.HasChanges)
End Function
The key to the updating is to write code in the handlers (textchanged??) to update the dataset.
Another method is to write your own custom listview (inherited from the generic listview) and add the necessary datasource code.