Windows フォームに DataGridView があり、2 つの列があり、最後の列にはパケットの名前が含まれます。ポイントは、この名前を複製する必要がないことです。
CellValidating イベントを使用してこのコードを試しました
string value = Convert.ToString(dgvTiendas.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
int cellIndex = e.RowIndex;
if(cellIndex == 1)
{
foreach (DataGridViewRow rw in dgvTiendas.Rows)
{
if (cellIndex == rw.Index)
{
return;
}
else
{
string valorRow = Convert.ToString(rw.Cells["ContenedorCodigoBarras"].Value);
if (value == valorRow)
{
MessageBox.Show("The container is already used");
dgvTiendas.Rows[e.RowIndex].ErrorText = "Contenedor ya utilizado";
e.Cancel = true;
}
else
{
e.Cancel = false;
}
}
}
}
アプリケーションを実行してコンテナの名前を書くと検証されますが、RowHeaderに「エラーテキスト」が表示されるため、現在のセルを検証しているようです。
これで数週間助けてください。