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

  • Home
  • SEARCH
  • 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 7959521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:35:13+00:00 2026-06-04T04:35:13+00:00

Using Csharp .NET4.0 and ms visual studio 2010. I have a really buggy problem

  • 0

Using Csharp .NET4.0 and ms visual studio 2010.

I have a really buggy problem that is to say the least bugging the hell out of me.

I have a datagridview that displays a league table of parts most sold. What the program does is allow the user to change the league positions around based on there own knowledge and judgement.

Once entering numbers in, the user can save there progress which updates a table on my MS SQL local server. But before the information is saved it runs a method that checks for any duplicated numbers in the column that has information being entered.

If it detects any duplicates it refuses to save, and informs the user with the part name displayed in another smaller datagridview. From here the user can then select the parts displayed and it will auto navigate and highlight the main datagridview for the user to make appropriate changes.

Now the Problem is the following, If a user enters a duplicate value, then clicks else where in the datagridview, then clicks save, the program runs correctly.

But if the user enters a duplicate value and goes straight to save, it bugs big time. Basically it saves the data that was there before the user entered data, also it does not show any duplicate values.

I believe this is because the cell that the user entered data in has not been updated.

I can provide some code if it will help. Just wandering if this is a common problem with a common fix?

Many Regards

CODE:

private void saveMyProgressToolStripMenuItem_Click(object sender, EventArgs e)
    {
        DialogResult result2 = MessageBox.Show("Do you wish to save you progress?",
                                                "Important Question",
                                                MessageBoxButtons.YesNo);
        if (result2 == DialogResult.Yes)
        {
            CheckForDuplicate();
            if (dupi == true)
            {
                CountMyGrid();
                dupi = false;
            }
            else
            {
                Task t = new Task(() => SaveMyWorkI());
                t.Start();
                dupi = false;
            }
        }
    }

The code above checks to see if it is ok to save or not based on the duplicate method boolean toggle.

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)//379
            {
                foreach (DataGridViewRow items in colls)//143641
                {
                    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;
                            }
                        }
                    }
                }
            }

            MyErrorGrid.DataSource = listParts.Select(x => new { Part = x }).ToList();

    }

if you excuse the constant checks for null types, this part cycles through detecting any duplicates.

If you require any more code just ask and ill be happy to provide.

  • 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-04T04:35:14+00:00Added an answer on June 4, 2026 at 4:35 am

    Try to apply the

    .Refresh() 
    

    function to the DataGridView. If that does not work try

    .EndEdit()
    

    Note that you should apply this right before saving the information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using SQL, SQL server manager 2008, c-sharp.net 4.0 and ms visual studio professional 2010:
I'm using Visual Studio 2010 to open files from a server, by going to
Using Visual Studio 2008, I need to create a custom web form that when
I inherited a C# Visual Studio 2010 project that I am unable to compile
Using MongoDB C# driver ( http://github.com/samus/mongodb-csharp ), seems that I'm unable to get the
I created windows service using csharp in that i am accessing shared folders which
I am working on a project using .Net mvc. I have a csharp class
I have application server that I wrote in csharp. The server is communicating with
I have created a console app referencing http://www.antlr.org/download/CSharp using System; using Antlr.StringTemplate; using Antlr.StringTemplate.Language;
I've been working on a process for programmatically generating Visual Studio projects using GetProjectTemplate.

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.