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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:34:26+00:00 2026-05-31T15:34:26+00:00

I am presenting a form as a dialog box. The form contains a DataGridView,

  • 0

I am presenting a form as a dialog box. The form contains a DataGridView, a TextBox and OK/Cancel buttons, as follows:

enter image description here

  • I have set the AcceptButton property of the form to the OK button and the CancelButton property of the form to the Cancel button.
  • I have set the DialogResult property of the OK button to “OK” and the DialogResult property of the Cancel button to “Cancel”

If the textbox has focus, then pressing Enter closes the form with a DialogResult of OK. However, if the DataGridView has focus then pressing Enter does not close the form.

Pressing the Escape key, however, always results in the form closing with a DialogResult of Cancel.

This is a two part question:

  1. What is the reason for the inconsistent behaviour of the Enter key when the DataGridView has focus?
  2. How can I cause Enter to close the form with a DialogResult of OK when the DataGridView has focus?
  • 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-31T15:34:27+00:00Added an answer on May 31, 2026 at 3:34 pm
    1. I imagine that enter is a valid key for data-entry, along with tab, and one that they want to preserve for those users who are most used to the keyboard, as opposed to point and click.

    2. Have you tried adding a call to PerformClick(), perhaps within your key-down event handler?

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

Sidebar

Related Questions

I have an MVC view that contains a JQuery UI dialog that can be
I currently have my form presenting additions to the form depending onChange of my
I have an jQuery.autocomplete field presenting a limited range of decimal numbers. Ex: var
So I have a normal form with 1 textarea and two hidden inputs, which
I'm thinking of presenting questions in the form of here is your input: [foo],
I have a form, and before it submits I want to check some of
I have this application (Windows form application written in Visual C++) from a colleague
Is it possible to use jQuery to disable the submit button of a form
I have some controls on a form, and I have them anchored to the
I am presenting my modal view using UIModalPresentationFormSheet and I am aware some have

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.