【问题标题】:Double-click DataGridView row using sql server?使用 sql server 双击 DataGridView 行?
【发布时间】:2020-02-25 10:13:34
【问题描述】:

当我双击行时,我遇到了这个错误。如何解决这个问题对我有帮助,对英语表示抱歉

提前致谢

【问题讨论】:

  • 也许 selRow 什么都不是
  • 请添加minimal reproducible example。我真的对 SQL Server 如何与 winforms 应用程序交互感兴趣。

标签: vb.net winforms datagridview


【解决方案1】:

永远不要发布代码图片。我们不能复制它并尝试一下。它对我有用,只需稍作改动。

Private Sub DataGridView1_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
    Dim aa = DataGridView1.CurrentRow.Cells(0).Value
    Dim selRow = dt.Select($"ID = {aa}")
    TextBox1.Text = selRow(0)("Type")
End Sub

我正在测试的 DataTable 中有一个名为 ID 的字段和一个名为 Type 的字段。我认为 DataRow 的 .Item 需要一个序数,所以我只使用了接受字符串的默认值。

【讨论】:

    猜你喜欢
    • 2011-04-24
    • 1970-01-01
    • 1970-01-01
    • 2017-03-09
    • 2016-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多