DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C# (http://www.daniweb.com/forums/forum61.html)
-   -   Buttons Enabled Property not Working Properly (http://www.daniweb.com/forums/thread201395.html)

S2009 Jul 3rd, 2009 1:17 am
Buttons Enabled Property not Working Properly
 
Hi all,

I am creating an Windows Application. I have two buttons.
I have written the following code snippet.

frmRb obj = new frmrb();
private void btnPd_Click(object sender, EventArgs e)
        {
          btnCancel.Enabled = true;
          obj.btnRtn.Enabled = true;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
            obj.BringToFront();
            obj.Focus();
        }


The above coding does not generate any error.

All the statements are working properly but the following statement is not working properly:

obj.btnRtn.Enabled = true;

is not executed.

The frmrb forms is bring to front and it is focussed but btnRtn is not Enabled that is the statement obj.btnRtn.Enabled = true; is not working.

By default I have set the property of btnRtn Enabled to false.
And Please note the Modifier property of btnRtn button is set to PUBLIC.

Now how should I change the coding so that I can get this statement executed.

obj.btnRtn.Enabled = true;

Can anybody help me out?

Thanks in Advance!!

adatapost Jul 3rd, 2009 2:49 am
Re: Buttons Enabled Property not Working Properly
 
Controls added to the form has private access.

Use following code:
Form2 a=new Form2();
a.Controls["button1"].Enabled=false;
a.Show();

S2009 Jul 3rd, 2009 3:06 am
Re: Buttons Enabled Property not Working Properly
 
Quote:

Originally Posted by adatapost (Post 907163)
Controls added to the form has private access.

Use following code:
Form2 a=new Form2();
a.Controls["button1"].Enabled=false;
a.Show();


Thanks for your prompt reply.

I added the code given by you, but still the button is not enabled.

What should I do to enable the button?

Please help me out!!

adatapost Jul 3rd, 2009 3:12 am
Re: Buttons Enabled Property not Working Properly
 
See my code
I have disabled it.

Form2 a=new Form2();
a.Controls["button1"].Enabled=True;
a.Show();

S2009 Jul 3rd, 2009 3:42 am
Re: Buttons Enabled Property not Working Properly
 
Quote:

Originally Posted by adatapost (Post 907175)
See my code
I have disabled it.

Form2 a=new Form2();
a.Controls["button1"].Enabled=True;
a.Show();

Thanks for your prompt reply.

Even when I change the enabled property to true.

The button is not enabled.

I don't know what s wrong with it.

Please can anybody help me out!!!

sknake Jul 3rd, 2009 12:15 pm
Re: Buttons Enabled Property not Working Properly
 
S2009:

You asked the same question in a different way on the thread
http://www.daniweb.com/forums/thread201290.html

I answered your question and then you ignore the post and asked the same question again -- slightly different.

adatapost Jul 3rd, 2009 12:25 pm
Re: Buttons Enabled Property not Working Properly
 
S2009,

Very pity!!!

Marked all those thread as "Solved".


All times are GMT -4. The time now is 2:51 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC