hey everyone i am new to vb.net program. I am currently working on a pizza ordering system. what i am doing is i am populating a combobox with pizza names from the menu datagridview. What i want to do now is to select the row that has the corresponding pizza name, then get the price of that pizza and multiply the pizza with the quantity entered and perform a calculation. Ireally need help i am done with everything else but this an i need to submit this in the next 24 hours please help!!!

Recommended Answers

All 5 Replies

You need help or you need someone to do it for you? If you need help, post the code that you have so far.

Reading you post I can understand your problem.
Your problem is
you have a datagridview of two columns. First is the name and second one is price. You want to pick up the price from datagridview and try to multiple with qty. and get the tot price.
May I right?
Please clear your problem

@santanu yes that is exactly what i needed.... thank you but i found an alternative to it.... thank you so much for helping

Why don't you create Variables for each Pizza_Price and assign it with correct Prices then on the datagridview you will just check if Beef Pizza for instance is selected then use the Beef_Pizza_Price I think that will be much easier.

 Dim Beef_Pizza_Price As Integer
 Beef_Pizza_Price = 15 ' The price for beef pizza
If DataGridView.SelectedItem.Equal("Beef Pizza") Then
Price = Beef_Pizza_Price
Else
If DataGridView.SelectedItem.Equal("Your other Pizza here") Then
Price = your other pizza prize
End If

That's how you can do it but if the columns has also prices then you should use the Index to track which Pizza is selected and assign the prices for it.

You do this, when you select a pizza name from DataGridView in DataGridView RowEnter Event.

 Private Sub DataGridView1_RowEnter(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.RowEnter
        'Store the Row Number into a variable
        PzRow = e.RowIndex 

        'Now multiply the Pizza quantity and price 
        'Display the total price in totalPrice TextBox
        TBoxTotPrice.Text = Format(Val(TBoxQty.Text) * Val(DataGridView1.Rows(PzRow).Cells(1).Value), "0.00")

    End Sub

Here, PzRow variable delcared as Integer Type at FormLevel to hold the Row Number you Clicked.
You have to do the same calculation at Quantity TextBox TextChange event, when you try to change the Qty of the Pizza.

Private Sub TBoxQty_TextChanged(sender As System.Object, e As System.EventArgs) Handles TBoxQty.TextChanged

        TBoxTotPrice.Text = Format(Val(TBoxQty.Text) * Val(DataGridView1.Rows(PzRow).Cells(1).Value), "0.00")

   End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.