Search in column datagridview return value coresponding value datadgridview vb.net -
i have datagridview in vb.net 3 columns
in first product description, in second product number , in 3rd price
i search in datagridview product number , return corresponding value in prices column.
i able search text in datagridviews @ current unable read value of corresponding cell such price cell.
so recap, want search product number return products price (to stored in variable further use)
i'm using vb.net
eddit:
private sub button33_click(byval sender system.object, byval e system.eventargs) handles button33.click dim rowindex string each row datagridviewrow in datagridview1.rows if row.cells.item("item_id").value = textbox5.text rowindex = row.index.tostring() dim actie string = row.cells("price").value.tostring() msgbox(actie) else msgbox("item not found") end if next end sub
allright, code update. this:
private sub button33_click(byval sender system.object, byval e system.eventargs) handles button33.click dim rowindex string dim found boolean = false each row datagridviewrow in datagridview1.rows if row.cells.item("item_id").value = textbox5.text rowindex = row.index.tostring() found = true dim actie string = row.cells("price").value.tostring() msgbox(actie) exit end if next if not found msgbox("item not found") end if end sub what loops through items. when finds match sets found true. if not item found "found" false when loop ends. , if "found" false display "item not found". hope understand, otherwise ask :)
Comments
Post a Comment