C#中列出重复项是很简单的,呵呵,只需要将下面一段代码放到按钮下面即可:


1 private void btndouble_Click(object sender, EventArgs e)
2 {
3 if (dt_tmp == null)
4 {
5 return;
6 }
7 DataTable dt_New = dt_tmp.Clone();
8 int count = 0;
9 foreach (DataRow item in dt_tmp.Rows)
10 {
11 foreach (DataRow row in dt_tmp.Rows)
12 {
13 if (item["产品信息"].ToString().Trim() == row["产品信息"].ToString().Trim())
14 {
15 count++;
16 }
17 }
18 if (count >= 2)
19 {
20 dt_New.ImportRow(item);
21 }
22 count = 0;
23 }
24 if (dt_New == null)
25 {
26 return;
27 }
28 rescdgv(dgvorders, dt_New);
29 //按照“产品信息”排序
30 dgvorders.Sort(dgvorders.Columns["产品信息"], ListSortDirection.Descending);
31 }
2 {
3 if (dt_tmp == null)
4 {
5 return;
6 }
7 DataTable dt_New = dt_tmp.Clone();
8 int count = 0;
9 foreach (DataRow item in dt_tmp.Rows)
10 {
11 foreach (DataRow row in dt_tmp.Rows)
12 {
13 if (item["产品信息"].ToString().Trim() == row["产品信息"].ToString().Trim())
14 {
15 count++;
16 }
17 }
18 if (count >= 2)
19 {
20 dt_New.ImportRow(item);
21 }
22 count = 0;
23 }
24 if (dt_New == null)
25 {
26 return;
27 }
28 rescdgv(dgvorders, dt_New);
29 //按照“产品信息”排序
30 dgvorders.Sort(dgvorders.Columns["产品信息"], ListSortDirection.Descending);
31 }
当点击dgv中的某一列复制产品信息,例如:


//点击DGV 将该行中的 手机号码 复制到剪切板中
private void dgvorders_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex != -1)
{
string value = dgvorders.CurrentRow.Cells["产品信息"].Value.ToString();
Clipboard.SetText(value);
}
}
private void dgvorders_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex != -1)
{
string value = dgvorders.CurrentRow.Cells["产品信息"].Value.ToString();
Clipboard.SetText(value);
}
}