G
Guest
Hi Cor
I spoke with u previously about this problem i had and u gave me some code that helped me. That code worked fine but i have now encountered another issuee that im hoping u may know how to solve
What my code below is doin is if a combobox and textbox is not empty, it is adding the items to a listview
The listview has 2 columns...
Product Quantit
What i want to do is to add the product along with the quantity into the listview only if that product has not been inserted previously. If it has been inserted previosly then i do not want a new row to be added but i simply want the quantity to be incremented
e.g if Nintendo 3 already exists in the lisview, if the user again selects nintendo with a quantity of 2, i do not want this entire row to be added again. I only want Nintendo 5 to be displayed (only the quantity should be updated).
what currently happens is that if the same product is added again the listview is searched and the quantity is correctly updated. However the problem i have at the momnet is that a new row is also inserted after the quantity has been updated. Does anyone know how i can stop this? This is my full code..
If Not ((CBoxProduct.Text = "") Or (txtQty.Text = "")) The
Dim Product As Strin
Product = CBoxProduct.Text.ToStrin
Dim Quantity As Intege
Quantity = txtQty.Tex
Dim Item1 As New ListViewItem(Product , 0
Dim item As ListViewIte
For Each item In LViewProductReq.Item
If item.Text = Product The
'if product is already in the listview, update the quantity instaed of addin a new
' row into the listvie
item.SubItems(1).Text = (CInt(item.SubItems(1).Text) + Quantity).ToStrin
Exit Fo
End I
Nex
'if the product does not exist in the listview i want to add it to the listvie
Item1.SubItems.Add(Quantity
'add the items to the listvie
LViewMealBookings.Items.Add(Item1
Els
'else display a message to state all required field are neede
MsgBox("Please ensure all the required fields are entered correctly"
End If
I spoke with u previously about this problem i had and u gave me some code that helped me. That code worked fine but i have now encountered another issuee that im hoping u may know how to solve
What my code below is doin is if a combobox and textbox is not empty, it is adding the items to a listview
The listview has 2 columns...
Product Quantit
What i want to do is to add the product along with the quantity into the listview only if that product has not been inserted previously. If it has been inserted previosly then i do not want a new row to be added but i simply want the quantity to be incremented
e.g if Nintendo 3 already exists in the lisview, if the user again selects nintendo with a quantity of 2, i do not want this entire row to be added again. I only want Nintendo 5 to be displayed (only the quantity should be updated).
what currently happens is that if the same product is added again the listview is searched and the quantity is correctly updated. However the problem i have at the momnet is that a new row is also inserted after the quantity has been updated. Does anyone know how i can stop this? This is my full code..
If Not ((CBoxProduct.Text = "") Or (txtQty.Text = "")) The
Dim Product As Strin
Product = CBoxProduct.Text.ToStrin
Dim Quantity As Intege
Quantity = txtQty.Tex
Dim Item1 As New ListViewItem(Product , 0
Dim item As ListViewIte
For Each item In LViewProductReq.Item
If item.Text = Product The
'if product is already in the listview, update the quantity instaed of addin a new
' row into the listvie
item.SubItems(1).Text = (CInt(item.SubItems(1).Text) + Quantity).ToStrin
Exit Fo
End I
Nex
'if the product does not exist in the listview i want to add it to the listvie
Item1.SubItems.Add(Quantity
'add the items to the listvie
LViewMealBookings.Items.Add(Item1
Els
'else display a message to state all required field are neede
MsgBox("Please ensure all the required fields are entered correctly"
End If