28-03-14, 07:24 PM
ضع على سبيل المثال على الفورم
4 textbox
2 button
1 datagridview
ثم اكتب هذا الكود
4 textbox
2 button
1 datagridview
ثم اكتب هذا الكود
كود :
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
' تهيئة الداتا جرد لاستقبال البيانات من مربعات النص
With DataGridView1
.DataSource = Nothing
.Rows.Clear()
.ColumnCount = 1
.Rows.Add(4)
.Rows(0).Cells(0).Value = TextBox1.Text
.Rows(1).Cells(0).Value = TextBox2.Text
.Rows(2).Cells(0).Value = TextBox3.Text
.Rows(3).Cells(0).Value = TextBox4.Text
End With
End Sub
Private Sub DataGridView1_CellContentClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
' كود جمع قيم العمود حيث
Dim i As Integer
Dim x As Integer
x = 0
For i = 0 To DataGridView1.Rows.Count - 1
x = x + DataGridView1.Rows(i).Cells(0).Value
Next
MsgBox(x)
End Sub
End Class