943,574 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1113
  • C# RSS
Jul 3rd, 2009
-1

Buttons Enabled Property not Working Properly

Expand Post »
Hi all,

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

C# Syntax (Toggle Plain Text)
  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!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
S2009 is offline Offline
67 posts
since Jun 2009
Jul 3rd, 2009
0

Re: Buttons Enabled Property not Working Properly

Controls added to the form has private access.

Use following code:
C# Syntax (Toggle Plain Text)
  1. Form2 a=new Form2();
  2. a.Controls["button1"].Enabled=false;
  3. a.Show();
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Jul 3rd, 2009
0

Re: Buttons Enabled Property not Working Properly

Click to Expand / Collapse  Quote originally posted by adatapost ...
Controls added to the form has private access.

Use following code:
C# Syntax (Toggle Plain Text)
  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!!
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
S2009 is offline Offline
67 posts
since Jun 2009
Jul 3rd, 2009
0

Re: Buttons Enabled Property not Working Properly

See my code
I have disabled it.

C# Syntax (Toggle Plain Text)
  1. Form2 a=new Form2();
  2. a.Controls["button1"].Enabled=True;
  3. a.Show();
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Jul 3rd, 2009
0

Re: Buttons Enabled Property not Working Properly

Click to Expand / Collapse  Quote originally posted by adatapost ...
See my code
I have disabled it.

C# Syntax (Toggle Plain Text)
  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!!!
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
S2009 is offline Offline
67 posts
since Jun 2009
Jul 3rd, 2009
1

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.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Jul 3rd, 2009
0

Re: Buttons Enabled Property not Working Properly

S2009,

Very pity!!!

Marked all those thread as "Solved".
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: close or overwrite the file
Next Thread in C# Forum Timeline: tooltip on mouse click





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC