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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:19:16+00:00 2026-06-17T14:19:16+00:00

I work on a system where most data collection forms are derived from a

  • 0

I work on a system where most data collection forms are derived from a base form.
Each form has an AcceptButton set, so that when the Enter key is pressed, the AcceptButton’s event it raised.
I want to be able to show a warning to the user asking if they are sure they want to save after pressing enter. If they select ‘yes’, the AcceptButton event will be raised, and if they select ‘no’, then nothing will happen.
Is this possible to do from the base class?
I’ve tried setting the AcceptButton to nothing in the base class in the ProcessCmdKey method if enter is pressed, but I don’t know how I can reset it again.

  • 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-17T14:19:17+00:00Added an answer on June 17, 2026 at 2:19 pm

    I think you’re on the right track with overriding the ProcessCmdKey method, but why set AcceptButton to nothing? An implementation like this should suffice

    Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, keyData As System.Windows.Forms.Keys) As Boolean
    
        If (keyData = Keys.Enter) Then
          If (MessageBox.Show("Do you want to save?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.No) Then
            Return True 'Eat the key press.
          End If
        End If
    
        Return MyBase.ProcessCmdKey(msg, keyData)
    
    End Function
    

    This will prompt the user when enter is pressed, and if they respond with No, then True is returned, indicating the key has been processed and no further processing will take place. This will prevent the Button.Click event from raising.

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

Sidebar

Related Questions

I've system that has a primary data model to perform most of the work.
I'm trying to recreate a SyndicationFeed object (System.ServiceModel.Syndication) from XML data that has been
We work on an internal corporate system that has a web front-end as one
I work on an internal corporate system that has a web front-end using Tomcat.
I frequently work with the System.IO namespace. Is there a way to have that
I am doing some work on an inbound call demand capture system where each
I've got a legacy system that processes extremely complex data that's changing every second.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; That's my namespaces. I
My application is fed data from an external device. After each data point, there
The work I do involves downloading into memory HUGE amounts of data from a

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.