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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:41:26+00:00 2026-06-14T20:41:26+00:00

When the user clicks on the cells, when it has a focus on it,

  • 0

When the user clicks on the cells, when it has a focus on it, if i want to open an another file, I’m getting an error message Argument Out Of Range Exception Error
I have added try catch & data Error event handler, still i’m getting this error. How can i fix this??

private void datagridview_CellValidating(object sender, CellValidatingEventArgs e)
{
try
{
    if (e.ColumnIndex == 2 || e.ColumnIndex == 3)
    {
        datagridview.Rows[e.RowIndex].ErrorText = "";
        int newInteger;
        if (datagridview.Rows[e.RowIndex].IsModified)
            return;
        if (!int.TryParse(e.Value.ToString(),
                          out newInteger) || newInteger < -50000 || newInteger > 50000)
        {
            e.Cancel = true;
            string errorMesssage = d_LanguageDropDownList.SelectedItem.ToString() == "French" ? "Entrez des valeurs décimales entre -50000 et 50000"
                          : "Enter decimal values between -50000 to 50000";
            datagridview.Rows[e.RowIndex].ErrorText = errorMesssage;
        }
    }

}
catch (Exception exception)
{
}

}
private void datagridview_DataError(object sender, GridViewDataErrorEventArgs e)
{

}

enter image description here

  • 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-14T20:41:27+00:00Added an answer on June 14, 2026 at 8:41 pm

    It is possible for the event to be called when no row is in the grid, or on the “New Row”, which doesn’t yet have an index. So you need to check whether RowIndex is >= 0 before indexing anything.

    If you set a breakpoint you will see that before the error occurs, RowIndex is -1.

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

Sidebar

Related Questions

When user clicks hyperlink on my ASP.NET page, I want a new browser to
When user clicks on select box , I want to hide the options menu
I have a UISearchDisplayController that displays some cells after a user has searched. After
I have a JTable which has certain cells editable. If the user enters in
I have two table views, when user clicks one cell of the first, second
I've got a dynamically filled datagrid view. When a user right clicks a cell
I have a table cell, and when the user clicks on it, I replace
When the user clicks on a button, a new ListFragment is displayed. This fragment
If a user clicks the blank row at the bottom of a DataGridView and
When the user clicks add more options, a from is created with javascript document.getElementById('addmore').innerHTML

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.