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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:49:28+00:00 2026-05-20T09:49:28+00:00

I find it hard to believe this hasn’t been asked before, but it doesn’t

  • 0

I find it hard to believe this hasn’t been asked before, but it doesn’t appear like it has been and my Google searches have all been for naught.

Can I set a maximum number of rows that a DataGridView will allow a user to add? (Like after adding the 10th row it will no longer display the ‘new row’ 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-20T09:49:29+00:00Added an answer on May 20, 2026 at 9:49 am

    There is no direct property to do this, but you should be able to accomplish this pretty easily using a combination of the AllowUserToAddRows property, and the UserAddedRow event.

    The general idea is to add an event handler to check the number of rows against the Maximum Allowed, and then set AllowUserToAddRows = false

    public partial class frmGridWithRowLimit : Form
    {
        public Int32 MaxRows { get; set; }
    
        public frmGridWithRowLimit()
        {
            MaxRows = 10;
    
            InitializeComponent();
    
            dgRowLimit.UserAddedRow += dgRowLimit_RowCountChanged;
            dgRowLimit.UserDeletedRow += dgRowLimit_RowCountChanged;
        }
    
        private void dgRowLimit_RowCountChanged(object sender, EventArgs e)
        {
            CheckRowCount();
        }
    
        private void CheckRowCount()
        {
            if (dgRowLimit.Rows != null && dgRowLimit.Rows.Count > MaxRows)
            {
                dgRowLimit.AllowUserToAddRows = false;
            }
            else if (!dgRowLimit.AllowUserToAddRows)
            {
                dgRowLimit.AllowUserToAddRows = true;
            }
        }
    }
    

    You will also want to handle when a user deletes a row to make sure that you allow them to add rows again.

    Hope this helps

    Cheers,
    Josh

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

Sidebar

Related Questions

I found this solution which works, but I find it hard to believe there
I'd like to know whether something like this has been done before: I've recently
unfortunately Dreamweaver doesn't support Asp.net mvc, and I find it hard to believe that
I'm trying to understand the concepts behind DDD, but I find it hard to
This is something that I always find a bit hard to explain to others:
Wow, it's hard to find a simple explanation to this topic. A simple many-to-many
It's hard to search for D using Google, so I wasn't able to find
I find it hard to believe that every developer creates their icons manually in
I've had a hard time trying to find good examples of how to manage
When using Mercurial I sometimes find that it is hard to understand the relationship

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.