vb.net - Get Result in Next Row in a DataGridView -
i have single row in datagridview shows different results selected oids..the problem next result replaces first 1 in same row..is there way next result in next rows datagridview can show previous results also..my datagrid not bound data source.
private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click dim host string dim community string host = datagridview1.rows(0).cells(1).value.tostring community = datagridview1.rows(3).cells(1).value.tostring dim txt4b new datagridviewtextboxcell() txt4b.value = "public" dim result dictionary(of oid, asntype) dim requestoid() string = nothing dim snmp new simplesnmp snmp = new simplesnmp(datagridview1.rows(0).cells(1).value.tostring, datagridview1.rows(3).cells(1).value.tostring) result = snmp.get(snmpversion.ver1, new string() {datagridview1.rows(1).cells(1).value.tostring()}) if not snmp.valid messagebox.show("invalid hostname/community") end if if result isnot nothing each kvp in result datagridview2.rows(0).cells(0).value = snmpconstants.gettypename(kvp.value.type) datagridview2.rows(0).cells(1).value = kvp.key.tostring datagridview2.rows(0).cells(2).value = kvp.value.tostring() next kvp else messagebox.show("no results received") end if datagridview2.autoresizecolumn(0) datagridview2.autoresizecolumn(1) datagridview2.autoresizecolumn(2) end sub
replace...
datagridview2.rows(0).cells(0).value = snmpconstants.gettypename(kvp.value.type) datagridview2.rows(0).cells(1).value = kvp.key.tostring datagridview2.rows(0).cells(2).value = kvp.value.tostring()
with this...
dim newrow new datagridviewrow dim cell1 datagridviewcell cell1.value = snmpconstants.gettypename(kvp.value.type) dim cell2 datagridviewcell cell2.value = kvp.key.tostring() dim cell3 datagridviewcell cell3.value = kvp.value.tostring() newrow.cells.add(cell1) newrow.cells.add(cell2) newrow.cells.add(cell3) datagridview2.rows.add(newrow)
this create new row values instead of overwriting existing values.
Comments
Post a Comment