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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:25:58+00:00 2026-06-13T11:25:58+00:00

I have a windows forms application with a DataGridView (DGV) on part of it.

  • 0

I have a windows forms application with a DataGridView (DGV) on part of it. I used the Visual Studio UI to add columns to the DGV and then programmatically added rows with some default values. My problem is once the rows are added, any cell selected automatically empties whatever value was in it – even read-only cells!

I am only handling the “CellValueChanged” event for the DGV, and all that does is validate the rows to make sure at least one valid combination of values exists and then enables a button.

To add to the confusion, the selected-cell-clearing issue does not always happen. After rows are added, until you make a change or perform an action that reloads the DGV with rows, all the cells will clear. After that either some or none of the cells will clear on their own.

Has anyone experienced this or know of a way to solve the problem? All I got from google was “how to make cells clear” and things like that.

Thanks,

  • Matt

* UPDATE *

Code for adding new rows to the DGV:

        metaMapGrd.Rows.Clear();
        ((DataGridViewComboBoxColumn)metaMapGrd.Columns[1]).DataSource = _excel.ListHeaders(worksheetListCmb.SelectedItem.ToString());
        foreach (Field f in _sharePoint.CurrentFieldList)
        {
            // skip the key field matching portion.  These should be for comparison only.
            if (f.Title == spListKeyCmb.SelectedItem.ToString())
            {
                continue;
            }

            DataGridViewRow row = new DataGridViewRow();

            metaMapGrd.Rows.Add(row);

            DataGridViewTextBoxCell spcell = new DataGridViewTextBoxCell();
            spcell.Value = f.Title;
            spcell.ToolTipText = f.TypeAsString;
            row.Cells["spListColumn"] = spcell;

            DataGridViewCheckBoxCell fcell = new DataGridViewCheckBoxCell();
            fcell.Value = true;
            row.Cells["useThisColumn"] = fcell;
        }
        metaMapGrd.CurrentCell = null;
  • 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-13T11:25:59+00:00Added an answer on June 13, 2026 at 11:25 am

    As per our chat, I suggest not trying to manually handle the DatagridView, but rather use an underlying List of DataObjects, and then databind the DGV to that list.

    Use a hidden column for the information about the SharePoint ColumnType.

    Hoipe this helps.

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

Sidebar

Related Questions

I have a WIndows Forms Application. I needed a DataGridView so i added one.
I have a Windows Forms application in C#/Visual Studio 2008 with an IE WebBrowser
I have a Windows Forms application that was created in Visual Studio 2008 and
I have a windows forms application containing a datagridview control. The datagridview is populated
In my Windows Forms Application, basically I have two DataGridView s. I want to
I have a Windows::Forms application and I want to add a custom control to
I have a Windows Forms application with a DataGridView in one of the forms.
I currently have a functioning in-house Windows Forms application which extensively uses the DataGridView
I am creating a Windows Forms Application using Visual Studio 2010. I populate data
I have windows forms application wich runs another console application here is the part

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.