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 3487306
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:08:00+00:00 2026-05-18T11:08:00+00:00

I have a .NET windows app. I have a DataGridView which has a few

  • 0

I have a .NET windows app.

I have a DataGridView which has a few rows in it. I had added a column containing buttons to allow the user to edit a row. This pops up a new form/dialog – my edit form.

// Add a CellClick handler to handle clicks in the button column.
dgv.CellClick += new DataGridViewCellEventHandler(dgv_CellClick);

The code which fires this is:

private void dgv_CellClick(object sender, DataGridViewCellEventArgs e)
{    
    if (e.ColumnIndex == buttonCell)
    {
        // Get the id number
        int number = Convert.ToInt32(dgv.Rows[e.RowIndex].Cells[0].Value);


        EditForm edit = new EditForm(number);
        edit.ShowDialog();                   
    }
}

Problem

My edit form displays (correctly). I make my changes, and close the form. It then loads again! It does this for the same number of rows in my Grid. Ie. It fires the code above once for each row in the DataGrid.

How can I prevent this? Is there a more elegant solution?

  • 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-05-18T11:08:00+00:00Added an answer on May 18, 2026 at 11:08 am

    I would make sure you’re not registering the CellClick event more than once.

    i.e., that you’re not calling this code more than once (like each time you add a row to your DGV):

    dgv.CellClick += new DataGridViewCellEventHandler(dgv_CellClick); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a .NET Windows service which has a WCF service built into
I have a .NET 2.0 windows forms app, which makes heavy use of the
JI have written a .NET C# Windows Form app in Visual Studio 2008 that
I have an old .net 2.0 windows app I need to deploy on a
We have about 7 app servers running .NET windows services that ping a single
I have a .NET application that contains a checkbox (System.Windows.Forms.Checkbox). This component (WindowsForms10.BUTTON.app.0.378734a1) is
I have a .NET Windows Service which spawns a thread that basically just acts
I have a simple Windows App written in Visual Studio 2008 (.NET 3.0, C#).
I am developing a .NET 3.5 Windows Forms app. I have two projects, the
I have a .NET 4 app which consists of the app and two class

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.