using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Q698769
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
Dictionary<int, string> dict = dataGridView1.Rows.Cast<DataGridViewRow>()
.Select((x, i) => new { x = (x.Cells[0].Value ?? "").ToString(), i })
.ToDictionary(x => x.i + 1, x => x.x);
if (dict.Any(x => x.Key != e.RowIndex + 1 && x.Value == dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString()))
{
MessageBox.Show("和" + dict.First(x => x.Key != e.RowIndex + 1 && x.Value == dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString()).Key.ToString() + "行重复");
}
}
}
}