وعليكم السلام ورحمة الله وبركاته
حتى لا يذهب مجهود الاخ عبد العزيز البسكري
خصوصاً عند قوله
(15-06-20, 12:49 AM)عبد العزيز البسكري كتب : امنذ الأمس و أنا أجرب و لم أتوصّل للحل المناسب ..
فاحببت اقوم بالشرح على المثل الخاص به لتوضح الصورة
فقط تعال على مشروعه وقم فى خصائص DataGridView1
عند خيار ContextMenuStrip واجعل قيمتها None
الان كل ما عليك اضافة الكود التالى
كود :
Private Sub DataGridView1_CellMouseDown(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseDown
Dim rowClicked As DataGridView.HitTestInfo = DataGridView1.HitTest(e.X, e.Y)
Dim getLocation As String() = Me.PointToClient(MousePosition).ToString().Replace("{", Nothing).Replace("}", Nothing).Replace("Y=", Nothing).Replace("X=", Nothing).Split(",")
If e.Button = Windows.Forms.MouseButtons.Right AndAlso e.RowIndex > -1 Then
DataGridView1.ClearSelection()
DataGridView1.Rows(e.RowIndex).Selected = True
ContextMenuStrip1.Show(DataGridView1, New Point(getLocation(0) - 10, getLocation(1) - 40))
End If
End Sub
الان كل ما عليك هو لكي يرفع او تقوم باذاحة القائمة وكذلك لليمين او اليسار
التعديل على كلاً من -10 و -40 لكى تلاحظ الفرق وبكده يتم عمل المطلوب