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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:30:31+00:00 2026-06-07T18:30:31+00:00

I have a DataGridView with a few DataGridViewComboBoxColumns. There is a CellEnter event handler

  • 0

I have a DataGridView with a few DataGridViewComboBoxColumns. There is a CellEnter event handler on the DataGridView for the purpose of single-click dropping down of the comboboxes.

The column is bound to a List of KeyValuePairs, ValueMember being “Key”, and DisplayMember being “Value”.

When I click on a combobox column, it works fine. However, if the cell is in the “dropdown” state and I click on another combobox (same column, different row), it properly deselects the old cell, selects and drops down the new cell, however the selected value on top changes to the value from the old cell for a split second, before changing back to the correct one.

For example, let’s say the list is A, B, C. In row1, A is selected, in row2, B is selected. I click the cell in row1, all is as it should be. Then, while this cell is dropped down, I click on the cell in row2. It drops down properly, but the selected value on top becomes A, then switches back to B (the correct one) immediately.

If I click on a cell in some other column before clicking the second combobox cell, this doesn’t happen.

Is there a way to prevent this from happening?

Example code to reproduce the problem (the event handlers are hooked up to the obvious events):

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PDGV
{
    public partial class Form1 : Form
    {
        List<KeyValuePair<string, string>> bindingList = new List<KeyValuePair<string, string>>();

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            dataGridView1.Rows.Add(10);
            bindingList.Add(new KeyValuePair<string,string>("aaa", "111"));
            bindingList.Add(new KeyValuePair<string,string>("bbb", "222"));
            bindingList.Add(new KeyValuePair<string,string>("ccc", "333"));
            bindingList.Add(new KeyValuePair<string,string>("ddd", "444"));
            bindingList.Add(new KeyValuePair<string,string>("eee", "555"));
            BindComboList(2, bindingList);

        }

        private void BindComboList(int columnIndex, object list)
        {
            var column = dataGridView1.Columns[columnIndex] as DataGridViewComboBoxColumn;
            if (column != null)
            {
                column.DataSource = new BindingSource(list, null);
                column.DisplayMember = "Value";
                column.ValueMember = "Key";
            }
        }

        private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
                return;

            dataGridView1.BeginEdit(true);
            var control = dataGridView1.EditingControl as DataGridViewComboBoxEditingControl;
            if (control != null)
                control.DroppedDown = true;
        }
    }
}
  • 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-07T18:30:32+00:00Added an answer on June 7, 2026 at 6:30 pm

    The Cuase:

    Deep down in DataGridView‘s EndEdit method it stores a copy of the previously used EditingControl this.latestEditingControl = this.editingControl; Then when you start editing another cell it Kicks in BeginEditInternal. During this it checks if the latestEditingControl is not null and the editing types are the same as the last cell, if so it reuses the control, which is why you see the flash, it really is the same control.

    The Solution:

    Set the latestEditingControl to null, this control is not accessible through normal properties/methods, have to use reflection. NOTE: This leads to a totally different annoyance, now the cell you are leaving flashes white :), but it does resolve the specific issue you asked for help on.

        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
                return;
    
            //this.latestEditingControl
            Type t = dataGridView1.GetType();
            FieldInfo viewSetter = t.GetField("latestEditingControl", BindingFlags.Default | BindingFlags.NonPublic | BindingFlags.Instance);
            viewSetter.SetValue(dataGridView1, null);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have few columns in my DataGridView, one of them is an unbound column
I have few columns in my DataGridView, and there is data in my rows.
I have few controls (Label, Custom Textbox, Datagridview) docked on a form. When I
I have DataGridView with two columns. The first column is TextBoxCol(DataGridViewTextBoxColumn) and the Second
I have datagridview with checkbox column, but I want, that some of the columns
I have a datagridview with a column with checkbox in it. What I am
I have a datagridview bound to a datasource, column[0] AgencyName is a primary key
I have a datagridview column 'total',in which I am doing sum of rates of
hi i have a datagridview whose first column (index = 0) is a checkbox
I have a DataGridView with a few DataGridViewComboBoxColumn's. The columns have their DataSource set

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.