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

  • Home
  • SEARCH
  • 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 6718979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:02:17+00:00 2026-05-26T09:02:17+00:00

I want to prevent the user clicking two times on a button when it

  • 0

I want to prevent the user clicking two times on a button when it has been already executing and the process is not finished.

I am using compact framework 3.5 and I have problems when the user clicks two times on a button that is already executing or some other button. I want to disable all buttons when the program is executing and enable them again when the process is done.

OS: Windows mobile 6.1
Framework: .NET 3.5 CF

  • 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-26T09:02:18+00:00Added an answer on May 26, 2026 at 9:02 am

    I found that I needed to do this quite often when building a windows mobile application so made a simple utility class.

    public static class FormUtility
    {
        /// <summary>
        /// Lock the form whilst processing
        /// </summary>
        /// <param name="controlCollection"></param>
        /// <param name="enabled"></param>
        public static void FormState(Control.ControlCollection controlCollection, bool enabled)
        {
            foreach (Control c in controlCollection)
            {
                c.Enabled = enabled;
                c.Invalidate();
                c.Refresh();
            }
        }
     }
    

    All I need to do was then call one line to lock the form down.

    FormUtility.FormState(this.Controls, false);

    You should end up with something like

     private void btnSave_Click(object sender, EventArgs e)
     {
          FormUtility.FormState(this.Controls, false);
    
          //Do your work
          if (!SaveSuccessful())
               //Renable if your validation failed
               FormUtility.FormState(this.Controls, true);
     }
    

    EDIT : I think what @tcarvin is suggesting is that you do not need to call refresh on every control but simply invalidate the controls and then refresh the container which will cause all the invalidated controls to redraw at once. I haven’t tested this but a small change to something like…

        public static void FormState(Form form, bool enabled)
        {
            foreach (Control c in form.Controls)
            {
                c.Enabled = enabled;
                c.Invalidate();
            }
    
            form.Refresh();
        }
    

    Then use

    FormUtility.FormState(this, true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I do not want to stop the user from clicking the same ajax button
I want prevent user to select dropdown list items using javascript methods. Is there
I want to prevent the user from maximizing the Windows Form to full screen
I have an HTML textarea element. I want to prevent a user from entering
I am working on a ASP.NET application. I want to prevent the user from
I want to prevent user from entering '>' and '<' character. How should i
Right now I want to prevent the user from pasting into a rich text
Hi i have develop an android application in which i want to prevent user
Is it any way to prevent user to go to specific web-pages using Adobe
I want to prevent user from uninstalling my application.But my main objective is to

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.