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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:04:57+00:00 2026-06-02T06:04:57+00:00

I have a very simple table with two string columns marked unique. Can anyone

  • 0

I have a very simple table with two string columns marked unique. Can anyone tell me how to wire up the datagridview to allow the most basic crud operations. I intend to use only the grid and no additional controls. This means having a link column for the delete operation.

I have tried a million iterations of having data tables, binding sources, data adapters, command builders..

Many thanks.

void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
{

}

private void bindingSource_PositionChanged(object sender, EventArgs e)
{
        // if the user moves to a new row, check if the 
        // last row was changed
        BindingSource thisBindingSource =
          (BindingSource)sender;

        DataRow ThisDataRow =
          ((DataRowView)thisBindingSource.Current).Row;
        if (ThisDataRow == _lastDataRow)
        {
            // we need to avoid to write a datarow to the 
            // database when it is still processed. Otherwise
            // we get a problem with the event handling of 
            //the DataTable.
            throw new InvalidOperationException("It seems the" +
              " PositionChanged event was fired twice for" +
              " the same row");
        }

        UpdateRowToDatabase();
        // track the current row for next 
        // PositionChanged event
        _lastDataRow = ThisDataRow;
    }

    private void UpdateRowToDatabase()
    {   
        if (_lastDataRow != null)
        {
            if (_lastDataRow.RowState == DataRowState.Modified
                || _lastDataRow.RowState == DataRowState.Added
                || _lastDataRow.RowState == DataRowState.Deleted)
            {
                DataRow[] rows = new DataRow[1];
                rows[0] = _lastDataRow;
                _dataAdapter.Update(rows);
            }
        }
    }        

void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
    {
        Debug.WriteLine(string.Format("Click Col: {0} Row:{1}", e.ColumnIndex, e.RowIndex));

        if (!_edit && e.ColumnIndex == 0)
        {
            if (e.RowIndex < _dataTable.Rows.Count)
            {
                DataRow[] rows = new DataRow[1];
                rows[0] = _dataTable.Rows[e.RowIndex];
                _bindingSource.RemoveCurrent();
                _dataAdapter.Update(rows);
            }
        }
    }
  • 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-02T06:05:00+00:00Added an answer on June 2, 2026 at 6:05 am

    See the ResultSetGrid class in the CodePlex project here: http://sqlcetoolbox.codeplex.com/SourceControl/changeset/view/77500#1210725

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

Sidebar

Related Questions

I have a very simple table with two columns, but has 4.5M rows. CREATE
This is a very simple example: I have a table with two columns, id
I have a very simple item ownership table with these two columns: UserID, ItemID
I have a simple data logging table with two data columns A and B
I have a very simple table: +----------+--------------+------+-----+---------+-------+ | Field | Type | Null |
I have the following PHP code doing a very simple select into a table.
I have a very simple webforms app that will allow field techs to order
I have a very simple table in access. The data is stored from VB.NET
I have a very simple access db with two tables linked by a 1-M
Fiddle demo available here: http://jsfiddle.net/r9MCW/5/ The functionality Basically, I have a very simple table

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.