0

我想累积在 datagridview 上的点击次数,但我总是获得 1 次点击

    Private Sub ClickMouse(sender As Object, e As DataGridViewCellMouseEventArgs) Handles LRInc.CellMouseClick
    MsgBox(e.Clicks & e.ColumnIndex & e.RowIndex)
End Sub
4

2 回答 2

0

MessageBox在第一次点击时显示,其他点击被忽略。您需要实现另一种方法来显示结果。

Private Sub ClickMouse(sender As Object, e As DataGridViewCellMouseEventArgs) Handles datagridview.CellMouseClick
    System.Diagnostics.Debug.Print(e.Clicks & e.ColumnIndex & e.RowIndex)
End Sub

结果应该在输出窗口中。

或者,您可以创建一个 TextBox ( Text1) 来保存结果

Private Sub ClickMouse(sender As Object, e As DataGridViewCellMouseEventArgs) Handles datagridview.CellMouseClick
        Text1.text = e.Clicks & e.ColumnIndex & e.RowIndex
End Sub

编辑 - 累积

声明和初始化:

Private Accums As New ArrayList

事件:

Private Sub ClickMouse(sender As Object, e As DataGridViewCellMouseEventArgs) Handles datagridview.CellMouseClick
  Accums.Add(New Integer() {e.Clicks, e.ColumnIndex, e.RowIndex})
End Sub
于 2013-05-18T21:45:32.920 回答
0

DataGridView中使用事件OnMouseDown

private void dataGridView1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Clicks == 1)
            {
                // Single Click occurred.
               label1.Text="Single Click";
            }
            if (e.Clicks == 2)
            {
                // Double Click occurred.
                label1.Text = "Double Click";
            }

        }
于 2013-05-18T19:03:29.733 回答