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

  • Home
  • SEARCH
  • 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 7010805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:02:46+00:00 2026-05-27T22:02:46+00:00

this is a follow up question from my previous one. you can find it

  • 0

this is a follow up question from my previous one. you can find it here.

I got another problem after finally solving my previous one, when I assign the button to add the value into a new row in DataGrid, the entire cell will be on edit mode, until I clicked on other cell and filled it and/or tabbed till the end of the row (well apparently this one doesn’t work), then it will end the edit mode.
I’m using dataGridView.BeginEdit(true); to begin the edit mode so that I could parse a value into the textbox (see my previous question). So, if I insert another value and press the button, the new value will replace the old value that was inserted previously because it is currently still on edit mode.
I was trying to use dataGridView.EndEdit();, dataGridView.EndEdit(DataGridViewDataErrorContexts.Commit);, cell.DataGridView.EndEdit() and cell.DataGridView.EndEdit(DataGridViewDataErrorContexts.Commit); but apparently that doesn’t end the edit mode 🙁
What I wanted is when I press the button, the value inside the textbox will be inserted into the first textbox column (this one already worked). Then I don’t have to click or fill the other column to end the edit mode. So, I’ll just type anything into the textbox and press the button only until I wanted to stop. After that I begin to fill the other column.
does anyone know how to solve this?
sample image
EDIT 1: do you see the difference? look at the red circle, the top one is currently in edit mode (because it has a * after the arrow). the bottom one is not in edit mode (I did it manually by picking an item from the combobox).
Here is my code as requested from my previous question:

private void button1_Click(object sender, EventArgs e)
    {
        this.surat_jalanDataGridView.AllowUserToAddRows = true;
        string tokNum = this.textBox1.Text;

        if (this.textBox1.Text != "")
        {
            foreach (DataGridViewRow sjRow in this.surat_jalanDataGridView.Rows)
            {
                int RowIndex = surat_jalanDataGridView.RowCount - 1;
                DataGridViewRow R = surat_jalanDataGridView.Rows[RowIndex];

                DataTable table = new DataTable();
                DataRow newRow = table.NewRow();
                table.Rows.Add(newRow);

                DataGridViewCell cell = R.Cells[2];
                this.surat_jalanDataGridView.CurrentCell = cell;
                this.surat_jalanDataGridView.BeginEdit(true);

                R.Cells[2].Value = tokNum;
                cell.DataGridView.EndEdit(DataGridViewDataErrorContexts.Commit);
            }
        }
        this.surat_jalanDataGridView.EndEdit(DataGridViewDataErrorContexts.Commit);
    }

EDIT 2: So, I drag and drop the surat_jalan from the data sources into my windows form. then it automatically become a datagrid with the property name surat_jalanDataGridView and the data source is surat_jalanBindingSource
img 2

  • 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-27T22:02:47+00:00Added an answer on May 27, 2026 at 10:02 pm

    Sorry about the delay. After seeing how you set up your binding to your DataGridView I can definately give you better guidance on how to edit the data that the grid is bound to. When you dragged the table from the data sources view in Visual Studio and dropped it on the DataGridView, Visual Studio did several things for you. It is important that you at least understand the basics of what was done so that you understand how you can manipulate you data moving forward. This
    MSDN article how to setup binding to windows forms controls from Visual Studio. The last section describes what you are doing. The last sentences “The DataGridView control is now bound to the table that you have dragged onto it. A DataSet, TableAdapter, and BindingSource appear in the component tray.” are the important ones. Since Visual Studio generated code that bound your control to your table you should edit the data directly to update your data grid view. In this case you should work with the generated DataSet (I’m assuming it was named surat_jalanDataSet). Here is a description of how to edit data in a DataSet. For your specific case Adding Rows. Please let me know if this helps you acheive your goals.

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

Sidebar

Related Questions

This is a follow-on question from the one I asked here . Can constraints
This is a follow up question from my previous one found here I need
All, this is a follow up from a previous question here: C# formatting external
Note that this is a follow-up question from my previous one: How to memorize
OK, this question is actually a follow-up question from my previous one: What would
This is a follow on from my previous question although this is about something
This problem follows on from a previous question . When I run the following
(This is a follow-up from this previous question ). I was able to successfully
This is a follow-on from a previous question, in the implementation, I have two
Follow on from a previous question One first screen activity I am clicking a

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.