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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:30:42+00:00 2026-05-26T04:30:42+00:00

I have a button that on click I would like to be disabled and

  • 0

I have a button that on click I would like to be disabled and it’s background image to be changed to null here is the code I have that happens on button click

    private void levelOne1001_Click(object sender, EventArgs e)
    {
        levelOne1001.Enabled = false;
        levelOne1001.BackgroundImage = null;
        scoreClass.genRandomNumber(100);
        scoreClass.valOfQuestion = 100;
        q1001 = true;
        openQuestionForm();
    }

And here is the code from openQuestionForm();

    private void openQuestionForm()
    {
        QuestionForm qForm = new QuestionForm();
        scoreClass.iCount++;
        qForm.Show();
        this.Hide();
    }

And here is where I call this form back up

     Level1Form l1Form = new Level1Form();
     l1Form.Show();

How the process works is Button on Original form is clicked goes to a Question form, button on Question form is clicked it goes back to Original Form. But when I go back to the original form the button is still enabled and the image is still there. Is there any way to fix this?

EDIT: Forgot to say this was in WinForms

  • 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-26T04:30:43+00:00Added an answer on May 26, 2026 at 4:30 am

    You are instantiating a new Level1Form, so it’s returning to its default state, causing the button to return to its default state. There are a few possible approaches:

    Add a parameter to Level1Form’s constructor that indicates what state the button should be in, something like

     Level1Form(bool enableButton) {
         initComponent();
    
         if(!enableButton) {
             levelOne1001.Enabled = false;
             levelOne1001.BackgroundImage = null;            
         }
      }
    

    Or, grab the same form again and reuse it. You will need to keep a reference to it somewhere and tell it to show itself again. Alternately, you can grab it out of Application.OpenForms

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

Sidebar

Related Questions

I have a button that I would like to disable when the form submits
I have a button that plays an audio file on its click listener. If
I have a button click event that takes information from controls and enters it
I have a page with a button that when I click, it retrieves data
Suppose, I want to have a link or a button that when user click
I have a hidden button on a form that I need to click in
I currently have a simple form that when you click the save button will
Hello StackOverflow'ers, I have a (flex) app that, on the click of a button,
I have ToggleButtons that are dynamically created based on my datasource. I would like
I have a vba userForm that has 36 buttons on it. I would like

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.