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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:48:52+00:00 2026-05-12T10:48:52+00:00

My problem seems to be quite simple, but it’s not working the intuitive way.

  • 0

My problem seems to be quite simple, but it’s not working the intuitive way.

I’m designing a Windows Forms Application, and there is a dialog that should NOT exit when the enter key is pressed, instead it has to validate data first, in case enter was pressed after changing the text of a ComboBox.

I’ve tried by telling it what to do on KeyPress event of the ComboBox if e is the Enter key:

Private Sub ComboBoxSizeChoose_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBoxSizeChoose.KeyPress
    If e.KeyChar = Convert.ToChar(Keys.Enter) Then
        Try
            TamanhoDaNovaFonte = Single.Parse(ComboBoxSizeChoose.Text)
        Catch ex As Exception
            Dim Dialogo2 As New Dialog2
            Dialog2.ShowDialog()
            ComboBoxSizeChoose.Text = TamanhoDaNovaFonte
        End Try
    End If
End Sub

But no success so far. When the Enter key is pressed, even with the ComboBox on focus, the whole dialog is closed, returning to the previous form. The validation is NOT done at all, and it has to be done before exiting. In fact, I don’t even want to exit on the form’s enter KeyPress, the only purpose of the enter key on the whole dialog is to validate the ComboBox (but only when in focus, for the sake of an intuitive UI).

I’ve also tried appending the validation to the KeyPress event of the whole dialog’s form, if the key is Enter. NO SUCCESS! It’s like my code wasn’t there at all.

What should I do?

(Visual Studio 2008, VB.NET)

  • 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-12T10:48:52+00:00Added an answer on May 12, 2026 at 10:48 am

    Make sure you don’t have a Button on the dialog that is set to something other than DialogResult.None.

    For example, if you have a button set to DialogResult.OK, it will act as the “default” button and close your form.

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

Sidebar

Related Questions

My problem seems to be quite simple, but I've been stuck on it for
My problem seems simple, but for some reason, I can't quite seem to fix
Im quite sure there is a very simple fix to my problem, but i
I am trying the strtok in visual c++, but it seems not working. This
My application is quite simple, but I have some problems when it starts. I
This is probably quite a simple problem, but it's causing me to scratch my
I have a (hopefully quite simple) Javascript problem. I've search but found nothing that
On the face of it, this seems a very simple problem but for some
Is there a simple way to export a WPF DataGrid to a text file
What I'm trying to do is quite simple but as a beginner I'm getting

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.