I have the following conflict, when trying to pass the values of each row of my datagrid to the other contours of my form since it only loads the values of the first row and I require that according to the row on which the user clicks. load the information of the first, second, third row etc, I leave the code that I am using to pass these values, I hope you can help me.
public void ValidaArticulosBD()
{
try
{
if (txtFolio.Text != "")
{
folioText = txtFolio.Text;
}
else
{
folioText = "";
}
if (folioText!="")
{
dtBuscaDetalle = objConsultas.MuestraDetalleArticulos(folioText);
if (dtBuscaDetalle.Rows.Count > 0)
{
dgvArticulos.DataSource = dtBuscaDetalle;
ArticuloDGV = dgvArticulos.CurrentRow.Cells[1].Value.ToString();
CantidadDGV = int.Parse(dgvArticulos.CurrentRow.Cells[2].Value.ToString());
preciounitarioDGV = dgvArticulos.CurrentRow.Cells[3].Value.ToString();
if (preciounitarioDGV.StartsWith("$"))
{
preciounitarioDGV1 = preciounitarioDGV.TrimStart('$');
preciounitarioDGV2 = double.Parse(preciounitarioDGV1);
}
detalleDGV = dgvArticulos.CurrentRow.Cells[4].Value.ToString();
DetalleDB = true;
}
else
{
dgvArticulos.DataSource = "";
DetalleDB = false;
}
}
}
catch (Exception ex)
{
ex.ToString();
}
}
private void dgvArticulos_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
try
{
ValidaArticulosBD();
if (ArticuloDGV!="")
{
dtArticulos1 = objConsultas.BuscaArticulos(ArticuloDGV);
if (dtArticulos1.Rows.Count > 0)
{
cmbIngresArticulo.Enabled = false;
cmbIngresArticulo.DataSource = dtArticulos1;
cmbIngresArticulo.ValueMember = "Art_ID";
cmbIngresArticulo.DisplayMember = "Art_Descripcion";
}
}
if (CantidadDGV > 0)
{
txtIngCantidad.Text = CantidadDGV.ToString();
}
if (preciounitarioDGV !="")
{
txtIngPU.Text = preciounitarioDGV2.ToString();
}
if (detalleDGV!="")
{
txtDescripcion.Text = detalleDGV;
}
}
catch (Exception ex)
{
ex.ToString();
}
}