06-12-19, 09:36 PM
(06-12-19, 08:10 PM)sofiane-phy كتب : السلام عليكم ممكن تصحولي هذا الكود من فظلكم
كود :
Private Sub Dgv1_KeyDown(sender As Object, e As KeyEventArgs) Handles Dgv1.KeyDown
Dgv1.CurrentCell.Selected = True
txt1.Text = Dgv1.CurrentRow.Cells(4).Value
txt2.Text = Dgv1.CurrentRow.Cells(5).Value
txt3.Text = Dgv1.CurrentRow.Cells(6).Value
txt4.Text = ((Dgv1.CurrentRow.Cells(4).Value + Dgv1.CurrentRow.Cells(5).Value) + (Dgv1.CurrentRow.Cells(6).Value * 3)) / 5
End Sub
عند النقر على السطر تظهر القيم في التكست بوكس مطابقة للسطر اما في حالة النزول الى الاسفل بالزر Dawon تظهر القيم التي قبلها لاحظ الصورة
يمكنك استخدام هذا الكود في Event
SelectionChanged
كود :
Private Sub Dgv1_SelectionChanged(sender As Object, e As EventArgs) Handles Dgv1.SelectionChanged
Try
Dim currentrw As Integer
currentrw = Dgv1.CurrentRow.Index
txt1.Text = Dgv1.Item(4, currentrw).Value.ToString()
txt2.Text = Dgv1.Item(5, currentrw).Value.ToString()
txt3.Text = Dgv1.Item(6, currentrw).Value.ToString()
txt4.text = (Val(txt1.text) + Val(txt2.text)) + (Val(txt3.text) * 3) / 5
Catch ex As Exception
End Try
End Sub
