Dear I am trying to delete records of two datagridview
at the same time by code match, I am loading the records in a datatable
both datagridview
,
The process is as follows: By selecting in the first table the exams that I removed from the second datagridview
the records that match the same code.
Public daat2 As New DataTable
'Cabeceras de las columnas del DataGridView
Public p_Codigo2 As New DataColumn("Codigo", GetType(System.String))
Public p_Codigo_examen As New DataColumn("Codigo2", GetType(System.String))
Public p_Denominacion2 As New DataColumn("Denominacion", GetType(System.String))
Public p_Precio_Costo2 As New DataColumn("Precio Costo", GetType(System.Decimal))
Public p_Precio_Venta2 As New DataColumn("Precio Venta", GetType(System.Decimal))
Private Sub Form_Gestion_Cotizaciones_Load(sender As Object, e As EventArgs) Handles MyBase.Load
p_Codigo2.Unique = True
'Agrego las columnas en el DataTable
With daat2.Columns
.Add(p_Codigo2)
.Add(p_Codigo_examen)
.Add(p_Denominacion2)
.Add(p_Precio_Costo2)
.Add(p_Precio_Venta2)
End With
DataGridView_Detalle_Cotizacion.DataSource = daat2
End Sub
Private Sub txt_Filtro_DataGridView_TextChanged(sender As Object, e As EventArgs) Handles txt_Filtro_DataGridView.TextChanged
daat2.DefaultView.RowFilter = "Codigo2=" & txt_Filtro_DataGridView.Text
End Sub
This is the code I'm using to remove the detail but it's working
Private Sub btn_Eliminar_Examen_Click(sender As Object, e As EventArgs) Handles btn_Eliminar_Examen.Click
Quitar_Examen_Detalle()
End Sub
Private Sub Quitar_Examen_Detalle()
Try
Dim da As DataTable
da = DataGridView_Cotizacion.DataSource
Dim filas As Integer = da.Rows.Count
Dim idd As String 'Integer
For i As Integer = 0 To da.Rows.Count - 1
idd = da.Rows(i).Item(0)
If idd = txt_Filtro_DataGridView.Text Then
da.Rows.RemoveAt(i)
Exit For
End If
Next
''Cargamos nuevamente los datos al datagridview mostrando los cambios
'dgv.DataSource = dt
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try