26-01-17, 11:51 AM
26-01-17, 01:15 PM
السلام عليكم
هذا الكود لتعطيل CheckBox بناء على قيمة العود الثاني (رقم 1)
هذا الكود لتعطيل CheckBox بناء على قيمة العود الثاني (رقم 1)
كود :
Private Sub DataGridView1_RowPostPaint(sender As Object, e As DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
Dim colCheckBox As Integer =
(From c As DataGridViewColumn In DataGridView1.Columns
Where TypeOf (c) Is DataGridViewCheckBoxColumn
Select c.Index).First
' تعطيل التشيكبوكس عندما تكون قيمة العمود الثاني أقل من 3
' العمود الاول رقمه صفر والعمود الثاني رقمه واحد وهكذا
If Val(sender.Item(1, e.RowIndex).Value) < 3 Then
sender.Item(colCheckBox, e.RowIndex).ReadOnly = True
sender.Item(colCheckBox, e.RowIndex).Style.BackColor = Color.LightGray
Else
sender.Item(colCheckBox, e.RowIndex).ReadOnly = False
sender.Item(colCheckBox, e.RowIndex).Style.BackColor = Nothing
End If
End Sub