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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:22:53+00:00 2026-06-06T05:22:53+00:00

I use DataGridView, and in some places I add control to it (e.g. textbox,

  • 0

I use DataGridView, and in some places I add control to it (e.g. textbox, combobox)

 dataGridView1.Controls.Add(comboBox);
 comboBox.Focus();

The problem is that using this control, and than commiting choice by using ENTER cause the DataGridView to “handle” the key -> after clickng enter instead of choosing sth from combobox, the selection in datagridview changes( moves to next cell).

I use sth like :

   public class MyDataGridView:DataGridView
{
    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
        if(keyData == Keys.Enter)
        {
            return true;
        }
        return base.ProcessCmdKey(ref msg, keyData);
    }
}

But it cause that datagridview and combobox doesn’t answer to ENTER, and other keys…

Additional infromation: I must use ComboBox class, instead of DataGridViewCombobox. Can anyone help me how to handle ENTER in my comobox?

  • 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-06T05:22:55+00:00Added an answer on June 6, 2026 at 5:22 am

    Try:

    if((keyData == Keys.Enter) && (MyComboBox.Focused))
    

    so DataGridView responds to ENTER except when your control is focused.

    I am not sure the following code fits your situation, but maybe you could try something like:

    public class MyDataGridView:DataGridView
    {
        public ComboBox MyComboBox { get; set; } //in case you had no other way to refer to it
    
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if((keyData == Keys.Enter) && (MyComboBox.Focused))
            {
                //commit choice logic
                return true;
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }
    }
    

    and from your form, if it needs, set the reference to your ComboBox:

    dataGridView1.Controls.Add(comboBox);
    dataGridView1.MyComboBox = comboBox;
    comboBox.Focus();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this problem: I have a datagridview that reads the data from a
I use DataGridView that gets Data from DataTable for editing some amount of data.
I use this to look for values in my DataGridView: private void fndBtn_Click(object sender,
I've just started to use dataGridView, and some things seem strange to me: when
I use DataGridView control to manage a simple dictionary (several columns and a few
Is there some sort of equivalent of CellMouseEnter from the winforms DataGridView control for
I am using WindowsFormsIntegration in a WPF project to add a DataGridView and I
I'd like to use the DataGridView control as a list with columns. Sort of
I have a datagridview control that where I need to color the rows based
I want to use datagridview for show some data(information) to user. My datagridview has

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.