How to add specific row from datagridview to listbox in VB.net -
when pressing button, want values specific row datagridview placed in listbox. example, when pressing budgie button, want details budgie, in row 1, placed in listbox (it's can calculate costs) however, when press button shows in listbox 'datagridviewrow { index=1 }' need change show values rather that?
private sub btnbudgie_click(sender object, e eventargs) handles btnbudgie.click
me.lstsales.items.add(datagridview1.rows(1))
end sub
this works if select whole row:
dim item string = "" try dim c integer = datagridview1.selectedrows(0).cells.count - 1 if c <= 0 c = 0 end if x = 0 c dim cell datagridviewcell = datagridview1.currentrow.cells(x) if x = datagridview1.selectedrows(0).cells.count - 1 item = item & cell.value else item = item & cell.value & " - " end if next listbox1.items.add(item) catch ex exception messagebox.show("an error occured. have selected whole row?" & environment.newline & ex.message, "error", messageboxbuttons.ok, messageboxicon.error) end try
Comments
Post a Comment