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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:00:59+00:00 2026-05-23T11:00:59+00:00

I have a DataGridView that loads data from a DataTable, along with an unbound

  • 0

I have a DataGridView that loads data from a DataTable, along with an unbound column of DataGridViewCheckBoxCells. The rows in the DataGridView are compared with a separate DataTable with values the user has saved, and if there is a match, the checkbox for that row should check.

Here is the code that compares the values and sets the checkbox value to ‘true’:

foreach (int j in selectedObjectives)
{
    foreach (DataGridViewRow r in dgvObjectives.Rows)
    {
        if (j == Convert.ToInt32(r.Cells["ObjectiveID"].Value))
        {
            dgvObjectives.CurrentCell = r.Cells["Select"];      
            ((DataGridViewCheckBoxCell)r.Cells["Select"]).Value = true;
            //dgvObjectives.InvalidateCell(r.Cells["Select"]);
            //dgvObjectives.EndEdit();
            //dgvObjectives.CommitEdit(DataGridViewDataErrorContexts.Commit);

        }
        if (Convert.ToInt32(r.Cells["ObjectiveID"].Value) == selectedIndex)
        {
            r.Selected = true;
        }
    }
}

When I call the method to perform this action during the form load private void WQMDrill_Load(object sender, EventArgs e), the values are set correctly, but the checkboxes do not check. However, when called after the form is finished loading, the code works perfectly. Unfortunately for me, I absolutely need for these to check during the load process.

I hope I was clear with my issue, any help on this matter would be greatly appreciated. As you can see, I have tried to invalidate the cell alone, as well as the entire DataGridView control. I also have

private void dgvObjectives_CurrentCellDirtyStateChanged(object sender, EventArgs e)
{
    if (this.dgvObjectives.CurrentCell.ColumnIndex == 0)
    {
        this.dgvObjectives.CommitEdit(DataGridViewDataErrorContexts.Commit);
    }
}

That doesn’t fire during this time. Thank you.

  • 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-23T11:01:00+00:00Added an answer on May 23, 2026 at 11:01 am

    You can put your checkbox selection and update logic in the DataBindingComplete eventhandler, this fires after the FormLoad but before anything is displayed to the user.

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

Sidebar

Related Questions

I have a datagridview that may or may not have rows selected when the
I have a DataGridView that I would like all values on a specific row
In my application I have a DataGridView control that displays data for the selected
Hey guys, I have an application that I want to display some data from
I have data that I'm taking from an Excel sheet with the ultimate goal
I have a dialog that containers a DataGridView, this dialog is opened from a
I have a datagridview that i bind from an sql table, in that dv
I have a datagridview that I've added a checkbox column to. When I preview
I have a datagridview control that where I need to color the rows based
I have a DataGridView that I want to query using Linq (C# WinForm). I

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.