DataGridView 中的 SNMP GetResponse

发布于 2024-11-24 13:39:41 字数 1372 浏览 0 评论 0原文

我想在数据网格视图中获取 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

海螺姑娘 2024-12-01 13:39:41

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文