Menangani Even DoubleClick Pada Devexpress GridView

Posted On // Leave a Comment

Penanganan double click pada DevExpress GridView ternyata tidak semudah yang saya bayangkan, karena harus memvalidasi apakah tempat kita doubleclick merupakan bagian dari suatu kolom/baris atau tidak.

setelah beberapa menit tanya ke mbah google, akhirnya nemu disini. Berikut script nya


Private Sub gridView1_DoubleClick(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.DoubleClick

        Dim view As GridView = CType(sender, GridView)

        Dim pt As Point = view.GridControl.PointToClient(Control.MousePosition)

        DoRowDoubleClick(view, pt)

    End Sub

    Private Shared Sub DoRowDoubleClick(ByVal view As GridView, ByVal pt As Point)

        Dim info As GridHitInfo = view.CalcHitInfo(pt)
        If info.InRow OrElse info.InRowCell Then

            Dim colCaption As String = ""
            If info.Column Is Nothing Then
                colCaption = "N/A"
            Else
                colCaption = info.Column.GetCaption
            End If

            MessageBox.Show(String.Format("Double click on row: {0}, column: {1}", info.RowHandle, colCaption))

        End If

    End Sub

0 komentar: