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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:57:52+00:00 2026-05-31T23:57:52+00:00

Friends, I’m using a datagridview control in my visual studio 2005 windows application. Here

  • 0

Friends, I’m using a datagridview control in my visual studio 2005 windows application. Here I’ve 5 columns. Among these 5, 2nd(colIndex 1) and 3rd(colIndex 2) column have text data type and 4th(colIndex 3)and 5th(colIndex 4) have double data type column. Now I’ve to check the cell value length for colIndex 1 and 2 whether the entered value length is greater than a specific(10 for colIndex 1 and 100 for colIndex 2) value? If so then I’ve to show corresponding message. Can you suggest in which datagridview event I should check the entered/typed cell value and how to check the value? I’ve used following code in CellValidating event

    string columnName = dgView.Columns[e.ColumnIndex].Name;

        if (dgView.Rows[e.RowIndex].Cells[dgViewColumn.TAN].Value.ToString().Length > 10)
        {
            e.Cancel = true;
            MessageBox.Show(columnName + " must be 10 Digits Long!");
        }

But it’s showing columnName of next column.
And as I’ve a feature for the grid that pressing “Enter” key will move the focus to next cell, it’s showing error as “Operation did not succeed because the program cannot commit or quit a cell value change.” in CellValidating event. Please help me.

  • 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-31T23:57:54+00:00Added an answer on May 31, 2026 at 11:57 pm

    I hope you know that the CellValidating event would be triggered for each cell, so maybe you are seeing the message since it might fail for the length part of the double datatype columns.

    So you should put a check that you are checking the first and second column respectively and then doing the checks for length.

    you can also choose to use e.FormattedValue to get the current value in the cell too.

    Also you can set the MaxInputLength for the Textbox column in the properties too (in case you need it)

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

Sidebar

Related Questions

Friends, I've a datagridview with 5 columns and 10 fixed rows. That means I've
Friends, I am developing third party application on Spotify. I am using Spotify Client
Friends I have been using Microsoft Visual C++ 2010 Express edition and also downloaded
friends. I know, there are many questions here already on these iterators. I've read
Friends i am making an application in which i am using Map Activity. Now
friends, i am opening google map application by using intents and URL to google
friends, i am using asp.net calendar control on page. dynamically i am assigning it
Friends, I have a question here. I'm developing an VS2010 - MVC 3 Application
Friends, I'm populating a GridView in my asp.net application using following code. GridView grdExport
Friends please help. I know that using jdk1.7 we can get the last access

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.