【问题标题】:Avoiding double click action in title of field name (DataGrid)避免在字段名称(DataGrid)的标题中双击操作
【发布时间】:2014-09-04 09:50:51
【问题描述】:

在 VB.NET (VS2008 .NET Framework 2.0) 中,我想在双击 DataGridView 的任何行时启动一个事件。我使用事件 CellContentDoubleClick 得到了这个,但问题是当我双击 DataGridView 的标题时,事件也会启动。我只是想避免标题中的动作。

我该如何解决这个问题?

提前致谢。

【问题讨论】:

    标签: vb.net datagridview


    【解决方案1】:

    CellContentDoubleClick 事件中,您可以使用以下代码检查是否单击了列/行标题:

    If e.ColumnIndex = -1 Or e.RowIndex = -1 Then
        'do what you want (maybe Exit Sub)
    End If
    

    如果您只需要停止列标题,请双击删除对e.RowIndex 的任何引用。

    【讨论】:

      猜你喜欢
      • 2021-11-10
      • 2017-02-05
      • 1970-01-01
      • 2012-04-07
      • 2020-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多