DataGridView 中的 SNMP GetResponse
我想在数据网格视图中获取 SNMP Getresponse..我在数据网格中绑定了一个数组..但问题是我在数据网格中没有得到任何响应,而是收到一个显示“未收到结果”的消息框..
如何才能我在 datagridView 中获取 Snmp GetResponse?
这是代码
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
I want to get the SNMP Getresponse in a datagridview..I have bind an Array in the datagrid..But the problem is i m not getting any response in datagrid instead i m getting a message box that shows "No results received"..
How can I get my Snmp GetResponse in a datagridView?
Here is the code
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SimpleSnmp 不是一个普通的类。 Microsoft .NET Framework 不包含这样的类,因此您可能会在 Internet 上的某个地方找到它。
如果你有源代码,你就必须自己调试。
SimpleSnmp is not a common class. Microsoft .NET Framework does not contain such a class, so you probably find it somewhere on the Internet.
Then you would have to debug on your own if you have its source code.