Buttons Enabled Property not Working Properly

Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Jun 2009
Posts: 67
Reputation: S2009 is an unknown quantity at this point 
Solved Threads: 0
S2009 S2009 is offline Offline
Junior Poster in Training

Buttons Enabled Property not Working Properly

 
-1
  #1
Jul 3rd, 2009
Hi all,

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

  1. frmRb obj = new frmrb();
  2. private void btnPd_Click(object sender, EventArgs e)
  3. {
  4. btnCancel.Enabled = true;
  5. obj.btnRtn.Enabled = true;
  6. }
  7.  
  8. private void btnCancel_Click(object sender, EventArgs e)
  9. {
  10. this.Close();
  11. obj.BringToFront();
  12. obj.Focus();
  13. }


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!!
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,420
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 430
adatapost's Avatar
adatapost adatapost is offline Offline
Nearly a Posting Maven

Re: Buttons Enabled Property not Working Properly

 
0
  #2
Jul 3rd, 2009
Controls added to the form has private access.

Use following code:
  1. Form2 a=new Form2();
  2. a.Controls["button1"].Enabled=false;
  3. a.Show();
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 67
Reputation: S2009 is an unknown quantity at this point 
Solved Threads: 0
S2009 S2009 is offline Offline
Junior Poster in Training

Re: Buttons Enabled Property not Working Properly

 
0
  #3
Jul 3rd, 2009
Originally Posted by adatapost View Post
Controls added to the form has private access.

Use following code:
  1. Form2 a=new Form2();
  2. a.Controls["button1"].Enabled=false;
  3. 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!!
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,420
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 430
adatapost's Avatar
adatapost adatapost is offline Offline
Nearly a Posting Maven

Re: Buttons Enabled Property not Working Properly

 
0
  #4
Jul 3rd, 2009
See my code
I have disabled it.

  1. Form2 a=new Form2();
  2. a.Controls["button1"].Enabled=True;
  3. a.Show();
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 67
Reputation: S2009 is an unknown quantity at this point 
Solved Threads: 0
S2009 S2009 is offline Offline
Junior Poster in Training

Re: Buttons Enabled Property not Working Properly

 
0
  #5
Jul 3rd, 2009
Originally Posted by adatapost View Post
See my code
I have disabled it.

  1. Form2 a=new Form2();
  2. a.Controls["button1"].Enabled=True;
  3. 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!!!
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,134
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 552
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Buttons Enabled Property not Working Properly

 
1
  #6
Jul 3rd, 2009
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.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,420
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 430
adatapost's Avatar
adatapost adatapost is offline Offline
Nearly a Posting Maven

Re: Buttons Enabled Property not Working Properly

 
0
  #7
Jul 3rd, 2009
S2009,

Very pity!!!

Marked all those thread as "Solved".
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC