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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:02:32+00:00 2026-06-18T10:02:32+00:00

I have a Windows Form with dgv. For now it’s just for presentational purposes

  • 0

I have a Windows Form with dgv. For now it’s just for presentational purposes so I use dummy data to populate one row with data. I also have a button named Add New Row which for just have to add new empty row in the dataGridView every time it’s clicked. For the initial populating of the dgv I use the load event of the form like this :

private void Form1_Load(object sender, EventArgs e)
{
    dataGridView1.AutoGenerateColumns = false;

    MyData td13 = new MyData();

    td13.colorCombinationColumn = "aff";

    td13.remarksColumn = "abcdddd";

    td13.prodColumn = true;

    td13.LastModifiedColumn = "ab";

    td13.ByColumn = "abc";

    MyData[] arr = new MyData[2];
    arr[0] = td13;

    dataGridView1.DataSource = arr;

}

Where MyData is this class :

public class MyData
{
    private int mId;

    private string mCombination;

    private string mremarks;

    private bool mprod;

    private string mLastModified;

    private string mBefore;


    public int Id
    {
        get
        {
            return mId;
        }

        set
        {
            ...

So far so good, but then I add my button and handle his click event:

private void btnAddRow_Click(object sender, EventArgs e)
{
    SoleData[] arr = new SoleData[1];
    dataGridView1.DataSource = arr;
}

And here is where the things go wrong. If I just dataGridView1.Rows.Add(1); is says Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound.. As you see I tried some other approaches but so far no success.

  • 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-18T10:02:33+00:00Added an answer on June 18, 2026 at 10:02 am

    Try to use a BindingList<MyData> instead of the MyData[] arr.
    Any modifications you do to the list will be reflected in the DGV, no further code necessary.
    (Also, declare the list as a private field of the form.)

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

Sidebar

Related Questions

I have one windows form file that each time I open it in Visual
I have windows form with one textbox(Pname) and one button. I have one class
I have Windows Form.Now i want to perform some function when the form get
I have windows form. I have put one loading image in PictureBox When I
I have a windows form, on which I display data from a local database.
I have one Windows Form with this.BackColor = Color.Red and this.TransparencyKey = Color.Red and
I have C# windows form application that queries data from a connected device. I
I have a windows form application. On the form there are three groupboxs. Each
I have a windows form app, and a class which is called Game. Let's
I have a windows form where in I open new threads for server communication.

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.