guys I have the following problem: I should look in a datagridview column if the value of a textbox is in one of the rows of that column, if the value coinicde, I should show a message that the time is occupied, otherwise , unlocks some controls and buttons. In theory it works, but I realized that it always works with the first cell that I select, with the others it fails the validation ... I have the following code that I execute in the click event of a button:
private void comparando()
{
foreach (DataGridViewRow row in dgvHorasAtencion.Rows)
{
string horaAtencion = Convert.ToString(row.Cells["hora"].Value);
if (this.textBox1.Text != horaAtencion)
{
MessageBox.Show("UPS, LA HORA ESTA OCUPADA");
hora = "";
this.label18.Visible = true;
this.label1.Visible = false;
return;
}
else
{
MessageBox.Show("DESBLOQUEA TODO, HORA LIBRE");
this.isNuevo = true;
this.isEditar = false;
this.botones();
this.limpiarControlesInsert();
this.habilitarControles(true);
groupBox2.Enabled = true;
this.label1.Visible = true;
this.label18.Visible=false;
return;
}
}
}
Does anyone notice any failure?
Greetings to all, watch out for your comments