0
我想要得到的SNMP GETRESPONSE在datagridview..I都綁定一個數組中的datagrid..But問題是我不是讓DataGrid中的任何響應,而不是即時得到一個消息框,顯示「沒有收到結果」 ..SNMP的GetResponse在一個DataGridView
我怎樣才能讓我的GetResponse的Snmp在一個DataGridView?
下面是代碼
Private Sub DataGridView2_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView2.CellContentClick
Dim dt As New DataTable()
Dim snmp As New SimpleSnmp
Dim kvp As KeyValuePair(Of Oid, AsnType)
Dim result As Dictionary(Of Oid, AsnType)
dt.Columns.Add(New DataColumn("Column1", GetType(SimpleSnmp)))
dt.Columns.Add(New DataColumn("Column2", GetType(Dictionary(Of Oid, AsnType))))
dt.Columns.Add(New DataColumn("Column3", GetType(KeyValuePair(Of Oid, AsnType))))
Dim dr As DataRow
dr = dt.NewRow()
dr("Column1") = New SimpleSnmp(DataGridView1.Rows(0).Cells(1).Value.ToString, DataGridView1.Rows(3).Cells(1).Value.ToString)
dr("Column2") = snmp.Get(SnmpVersion.Ver1, New String() {DataGridView1.Rows(1).Cells(1).Value.ToString()})
If Not snmp.Valid Then
MessageBox.Show("Invalid hostname/community")
End If
If result IsNot Nothing Then
For Each kvp In result
dr(0) = SnmpConstants.GetTypeName(kvp.Value.Type)
dr(1) = kvp.Key.ToString
dr(2) = kvp.Value.ToString()
Next kvp
Else
MessageBox.Show("No results received")
End If
dt.Rows.Add(dr)
DataGridView2.DataSource = dt
End Sub