+ Reply to Thread
Results 1 to 2 of 2

Thread: enabling button on form

  1. #1
    Junior Member
    Join Date
    Jun 2012

    enabling button on form

    I have a form1, there's a "download" button, and a "next" button. By default, the "next" button is disabled. When I click "download" button, I will call a method from download.cs, different from form1.cs. After downloading, I want the "next" button to be enabled, so in download.cs, after receiving all files, I put

    form1.btnNext.Enabled = true;

    But it doesn't work. I also put this in form1.cs

    public void enableButton(bool enabled)

    { btnNext.Enabled = enabled; }

    and in download.cs I put:

    private form1 form1; ...


    but it doesn't work either. Could any1 show me where I'm wrong?

  2. #2
    Junior Member
    Join Date
    Jun 2012
    If you are freezing your UI while download than

    1- Define an event in your Downloader class

    public delegate void EnableUI(bool shdEnable);

    public event EnableUI MakeUIEnabled;
    2- Hook this event in your form1 class , i assume that you are creating an object of download class in the download button or it is created at class level , lets say this object as customDownloader

    customDownloader.MakeUIEnabled+=new EnableUI(EnableUIControls);
    3- Define a event hander in form1 class as shown below.

    public void EnableUIControls(bool shdEnable)
    btnNext.Enabled = shdEnable;

    4- Let's sya that there is a downloadfile() method in download.cs file so when your download is completed than raise this event.

    public void DownLoadFile()


+ Reply to Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts