VB DataGridView CellMouseClick事件阻止CellMouseDoubleClick

时间:2015-06-18 13:16:29

标签: vb.net datagridview mouseevent

我使用Visual Basic编写WinForm应用程序。在我的DataGridView中,我将Selection Mode属性设置为CellSelect。我正在尝试设置我的DataGrid,以便在单击时,一些文本框中填充了一些数据,并且在双击时,它将打开一个新表单并显示各种其他信息。

我已尝试过CellClick + CellDoubleClick事件以及CellMouseClick + CellMouseDoubleClick但是,每次双击时,单击事件都会先触发并阻止双击事件被触发。

也许这只是我缺乏理解而我需要做一些不同的事情,我想到只需添加一个按钮列并触发buttonclick事件,但由于我硬编码,这将需要大量重新编码现有的数据列属性,如Column(1 ... 15).visible = false等等。任何人都有任何想法如何让两个事件都被解雇?

双击事件

Private Sub DataGridView1_CellDoubleClick(sender As Object, e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseDoubleClick
    CallLookup.ShowDialog()
    Dim PatientID As String = SelectGrid.Rows(SelectGrid.CurrentRow.Index).Cells("PatientID").Value.ToString
    PatientID = CallLookup.patientID2
End Sub

单击

 Private Sub DataGridView1_CellMouseClick1(sender As Object, e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseClick
  Dim reader As SqlClient.SqlDataReader = mycommand.ExecuteReader
        While reader.Read
            Dispatchtxt2.Text = (reader("PickupDispatchedTime").ToString)
            Enroute2Txt.Text = (reader("PickupEnRouteTime").ToString)
            OnScene2Txt.Text = (reader("PickupOnSceneTime").ToString)
            Transport2Txt.Text = (reader("PickupTransportTime").ToString)
            Arrival2Txt.Text = (reader("PickupArrivalTime").ToString)
            clear2txt.Text = (reader("PickupClearTime").ToString)
   End While
        DataGridView1.Refresh()
        DataGridView1.InvalidateRow(DataGridView1.CurrentRow.Index)
    Else
    End If
End Sub

我留下了几行只是一个数据连接

0 个答案:

没有答案