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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:18:42+00:00 2026-06-17T20:18:42+00:00

I have an unbounded DataGridView with several columns. I’ve created a CellValidating function, and

  • 0

I have an unbounded DataGridView with several columns. I’ve created a CellValidating function, and it works well. Right now I’m trying to read data in from a text file and put it in the DataGridView. When I do this however, the CellValidating function never gets called. Is it possible to validate data entered like this?

Edit: Here’s part of my CellValidate function:

private void Grid_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
    string headerText = Grid.Columns[e.ColumnIndex].HeaderText;

        switch (headerText)
        {
            case "Number":

                if (!String.IsNullOrEmpty(e.FormattedValue.ToString()))
                {
                    if (!Regex.IsMatch(e.FormattedValue.ToString(), @"(^\d{1,2}$)"))
                    {
                        MessageBox.Show("Number must be a 1 or 2 digit positive number");
                        e.Cancel = true;
                    }
                }
        }
}
  • 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-17T20:18:43+00:00Added an answer on June 17, 2026 at 8:18 pm

    CellValidating and RowValidating events fire when the current cell/row is being changed or when ending an edit operation. You should be able to force the validation trigger using BeginEdit and EndEdit.

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

Sidebar

Related Questions

I have a form created which an unbound datagridview that has three columns. Position,
I have a Java code where the return type of a function has unbounded
I have few columns in my DataGridView, one of them is an unbound column
I am using a Datagridview (unbounded mode) and I have selected enable adding in
I'm new to using the C#/.NET programming Language and I have created a DataGridView
I'm having some trouble with VisualStudio 2010 C# Winforms. I have created a DataGridView
I have a unbound DataGridView with two columns. First column is just string values.
I have an unbound datagridview with 175 columns and 50,000 rows, populated primarily with
On a Windows form I have an unbound datagridview with 1 user-editable column. A
I have a DataGridView in a Winforms app that has about 1000 rows (unbound)

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.