Private Sub SearchFullNameInDataGridView(keyword As String)
Dim foundMatch As Boolean = False ' متغير لتتبع ما إذا كان هناك تطابق في البحث
With DataGridView1
For Each row As DataGridViewRow In .Rows
If Not row.IsNewRow Then
Dim cellValue As String = row.Cells("Column1").Value.ToString()
If String.Equals(cellValue, keyword, StringComparison.OrdinalIgnoreCase) Then
row.Selected = True
.CurrentCell = row.Cells("Column1")
row.Cells(1).Value += 1
row.Cells(3).Value = Val(row.Cells(2).Value) * Val(row.Cells(1).Value)
foundMatch = True ' هناك تطابق في البحث
Exit For
End If
End If
Next
If Not foundMatch Then
' لا يوجد تطابق في البحث، قم بإضافة الصف الجديد
.Rows.Add(TextBox1.Text, TextBox5.Text, TextBox6.Text, Val(TextBox5.Text) * Val(TextBox6.Text))
End If
End With
End Sub