Refreshing just one cell in Datagridview?

  • Thread starter Thread starter ScottNYG
  • Start date Start date
S

ScottNYG

Guest
Hello all, this is a work project Im attempting to add the ability of customer service to change the value of a cell(Quantity) and after they tab away, click away from that cell the cell value for Price should update!! It updates in the database but not on my datagridview and it perplexing me. Ive read alot of forums and nothing seems to hone in on what I exactly need. I am using the cellValueChanged function supplied with datagridview. These are bound dataset(datasource?) btw. So my grid is like th

PartNbr Qty Price

LVB7654 4 $23.99

If I change Quant to 3 lets say I want Price to update right away! after editing qty and tabbing, clicking away. I dont understand how microsoft makes this crap so complicated its ridiculous!!!!!

Cell Value Changed Function


If DGView.Rows.Count >= 0 Then
If e.RowIndex >= 0 Then
Me.DGView.Rows(e.RowIndex).Cells("PartNbr").Value = 1
Console.WriteLine("Here")
If e.ColumnIndex = 1 Then We have to grab the partNum and find the unit price in Pricing table and recalc new price
Dim strPartNum As String = DGView.Rows(e.RowIndex).Cells(0).Value
Dim Quantity As Integer = CInt(DGView.Rows(e.RowIndex).Cells(1).Value)
query = "SELECT CPN from ItemMaster Where Item_Nbr LIKE " & strPartNum & ""
rs = frmHeader.GetRecSet(query)
If (rs.BOF <> True And rs.EOF <> True) Then
CPN = rs.Fields("CPN").Value
query = "SELECT Current_price from Pricing Where RIGHT(ID,5) like " & CPN & ""
rs = frmHeader.GetRecSet(query)
Dim price# = rs.Fields("Current_price").Value * Quantity
query = "UPDATE CompBOM SET Qty = " & Quantity & " , Price = " & price# & " WHERE HeaderCounter LIKE " & frmHeader.txtAutoNumber.Text & " AND LabelName LIKE " & mbLabel & " AND PartNbr LIKE " & strPartNum & ""
rs = frmHeader.GetRecSet(query)

DGView.Update() -doesnt work!!

Continue reading...
 
Back
Top