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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:25:17+00:00 2026-05-14T16:25:17+00:00

This is in my RowValidation function of DataGridView: DataGridViewRow row = viewApplications.Rows[e.RowIndex]; if (row.Cells[colApplyTo.Index].Value

  • 0

This is in my RowValidation function of DataGridView:

        DataGridViewRow row = viewApplications.Rows[e.RowIndex];
        if (row.Cells[colApplyTo.Index].Value == (object)-1) {
            if (MessageBox.Show("Row #" + (e.RowIndex + 1) + " is not assigned to a charge. Would you like to correct this? (If no, the row will be deleted)", "Invalid Row", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) {
                viewApplications.Rows.RemoveAt(e.RowIndex);
            } else {
                e.Cancel = true;
            }
        }

However, there is a problem, if the user says no, meaning he or she does not with to correct this row, I cannot delete it like I try to do. I get the exception: InvalidOperationException: Operation cannot be performed in this event handler

How can I correct this and still remove the row?

  • 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-14T16:25:18+00:00Added an answer on May 14, 2026 at 4:25 pm

    To remove the row outside the handler, you can call BeginInvoke:

    BeginInvoke(new Action(delegate { viewApplications.Rows.RemoveAt(e.RowIndex); }));
    

    This will run the code in the delegate during the next message loop.

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

Sidebar

Related Questions

This is my bitmap object Bitmap b = new Bitmap(columns, rows, PixelFormat.Format8bppIndexed); BitmapData bmd
This link describes a function on a Money object for adding funds together of
this ajax function gets a textbox value and sends it to response.php : (this
This should be exceptionally simple. I have a zoo object with 500 times series
this.update = function() { if (state == game) { if (jaws.pressed(p) && !jaws.paused) {
I'm trying to delete a row from a DataGridView I use two types of
I need to get the currently selected object from da databound DataGridView. I do
this is most likely very easy but i'm struggling $(window).bind(load resize, function(){ var wH
This is essentially what I want to do: public abstract class Uniform<T> { public
This more of a style question, rather than a how to. So I've got

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.