How to list repeated items in C #

Source: Internet
Author: User

Listing repeated items in C # is very easy. You just need to put the following code under the button:

List repeated items

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 ["Product Information"]. ToString (). Trim () = row ["Product Information"]. 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 // sort by "product information"
30 dgvorders. Sort (dgvorders. Columns ["Product Information"], ListSortDirection. Descending );
31}

Click a column in dgv to copy the product information, for example:

Copy information

// Click DGV to copy the phone number in the row to the clipboard.
Private void dgvorders_CellClick (object sender, DataGridViewCellEventArgs e)
{
If (e. RowIndex! =-1)
{
String value = dgvorders. CurrentRow. Cells ["Product Information"]. Value. ToString ();
Clipboard. SetText (value );
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.