Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8134279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:57:25+00:00 2026-06-06T09:57:25+00:00

Morning guys. Using C sharp .net4, and MS Visual Studio 2010. I have Developed

  • 0

Morning guys.

Using C sharp .net4, and MS Visual Studio 2010.

I have Developed a duplication checker for my windows form program.
It works perfectly and Is virtually Instant on my Datagrid when there are a couple hundred records.

The problem I’ve noticed is that when there are 6000 records displayed it is not efficient enough at all and takes minutes.

I was wandering if anyone has some good tips to make this method a lot faster either improving upon the existing design or, a different method all together that I’ve over looked.

Your help is once again much appreciated!

Here’s the code:

public void CheckForDuplicate()
{
    DataGridViewRowCollection coll = ParetoGrid.Rows;
    DataGridViewRowCollection colls = ParetoGrid.Rows;
    IList<String> listParts = new List<String>();
    int count = 0;

    foreach (DataGridViewRow item in coll)
    {
        foreach (DataGridViewRow items in colls)
        {
            count++;
            if ((items.Cells["NewPareto"].Value != null) && (items.Cells["NewPareto"].Value != DBNull.Value))
            {
                if ((items.Cells["NewPareto"].Value != DBNull.Value) && (items.Cells["NewPareto"].Value != null) && (items.Cells["NewPareto"].Value.Equals(item.Cells["NewPareto"].Value)))
                {
                    if ((items.Cells["Part"].Value != DBNull.Value) && (items.Cells["Part"].Value != null) && !(items.Cells["Part"].Value.Equals(item.Cells["Part"].Value)))
                    {
                        listParts.Add(items.Cells["Part"].Value.ToString());

                        dupi = true; //boolean toggle
                    }
                }
            }
        }
    }  
    MyErrorGrid.DataSource = listParts.Select(x => new { Part = x }).ToList();     
}

Any Questions let me know and I will do my best to answer them.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:57:27+00:00Added an answer on June 6, 2026 at 9:57 am

    If you can, you should try and do this on the underlying data rather than on the UI objects – however I have a hunch that you’re seeding it from a set of DataRows, in which case you might not be able to do that.

    I think a big part of the issue here is the repeated dereferencing of the cells by name, and the fact that you repeatedly deference the second set of cells. So do it all up front:

    var first = (from row in coll.Cast<DataGridViewRow>()
                let newpareto = row.Cells["NewPareto"].Value ?? DBNull.Value
                let part = row.Cells["Part"].Value ?? DBNull.Value
                where newpareto != DBNull.Value && part != DBNull.Value
                select new 
                { newpareto = newpareto, part = part }).ToArray();
    
    //identical - so a copy-paste job (if not using anonymous type we could refactor)
    var second = (from row in colls.Cast<DataGridViewRow>()
                let newpareto = row.Cells["NewPareto"].Value ?? DBNull.Value
                let part = row.Cells["Part"].Value ?? DBNull.Value
                where newpareto != DBNull.Value && part != DBNull.Value
                select new 
                { newpareto = newpareto, part = part }).ToArray();
    
    
    //now produce our list of strings
    var listParts = (from f in first
                    where second.Any(v => v.newpareto.Equals(f.newpareto)
                                       && !v.part.Equals(f.part))
                    select f.part.ToString()).ToList(); //if you want it as a list.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Morning All, I have been writing an ever so simple IRC client in visual
Morning Guys, I have a few ComboBoxes bound to List of TimeSpan. I am
Morning Guys, I have a CSS issue that's driving me up the wall. I
Morning, I have a strange problem with the Zend Form Validator. When I want
Good morning/afternoon/evening guys Here is the thing. I'm making a registering gsp that it
Hai Guys, My application deals scheduled mail concept (i.e) every morning 6.00 am my
Hai guys, I want to send scheduled mail every morning from my application and
Good morning! I would like to ask some help from you guys on how
Morning stackoverflow, I have a repeater, with the following code in my aspx page;
Morning, I have the following HTML: <div id=sah_padding> <div id=sah_holder> <div id=sah_name>Hello [agent_name]</div> <div

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.