Kamis, 05 Maret 2015

Datagrid Right Click Popup

==========================================================
RIGHT CLICK POPUP

---------------------------------------------------------------------------------------------------
<pre class="brush: csharp">
Private Sub DataGridView1_CellMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseDown
        If e.RowIndex < 0 Or e.ColumnIndex < 0 Or e.RowIndex > DataGridView1.Rows.Count Then
            DataGridView1.ContextMenuStrip = Nothing
            Exit Sub
        End If
        DataGridView1.ContextMenuStrip = ContextMenuStrip1
        If _Daduk.meIdX(DataGridView1.Item(0, e.RowIndex).Value) = False Then Exit Sub
        If e.Button = Windows.Forms.MouseButtons.Right Then
            ContextMenuStrip1.Items(0).Text = _Daduk.Field(3)
            ContextMenuStrip1.Show(Me.DataGridView1, New Drawing.Point(e.X, e.Y))
        End If
    End Sub
</pre>
==========================================================
JIKA SHDK BERUBAH
---------------------------------------------------------------------------------------------------
    Private Sub _list_e_ColChage(ByVal value As String, ByVal rw As System.Data.DataRow, ByVal cl As System.Data.DataColumn) Handles _list.e_ColChage
        If cl.ColumnName = "u" And Microsoft.VisualBasic.Left(value, 1) = "4" Then
            If _list.f_dummy("select * from penduduk where g='" & rw.Item("g") & "'").Rows.Count < 1 Then Exit Sub
            For i As Integer = 0 To _list.f_dummy.Rows.Count - 1
                If _list.f_dummy.Rows(i).Item(19) = "1" Then rw.Item("y") = _list.f_dummy.Rows(i).Item(4) : rw.Item("z") = _list.f_dummy.Rows(i).Item(3)
                If _list.f_dummy.Rows(i).Item(19) = "3" Then rw.Item("w") = _list.f_dummy.Rows(i).Item(4) : rw.Item("x") = _list.f_dummy.Rows(i).Item(3)
            Next
        End If
    End Sub 'SHDK Berubah
===========================================================
DOUBLE CLICK
----------------------------------------------------------------------------------------------------
    Private Sub DataGridView1_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
        If e.RowIndex < 0 Or e.ColumnIndex < 0 Then Exit Sub
        DataGridView1.DataSource = _list.f_Query("select * from penduduk WHERE g ='" & DataGridView1.Item(6, e.RowIndex).Value & "' order by int(u) ASC,right(n,4) ASC")
    End Sub

Foto Propades