Check Whether Button Clicked or not - Please Help

Please support our C# advertiser: Intel Parallel Studio Home
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

Check Whether Button Clicked or not - Please Help

 
0
  #1
Jul 2nd, 2009
Hi all,

I am creating an Windows application.

I have 2 forms.

In First form I have two buttons. The Second Buttons Enabled property is set to False.

If the First button is clicked then Form 2 should be shown which I have done with the Coding.

In the second Form I have one button If this button is clicked then it should show first form and the second button of that form should be enabled (Enabled property to be set to TRUE).

Can anyone help me out in doing this task?

Please help me out.

Thanks in advance!!
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,187
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: 571
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Check Whether Button Clicked or not - Please Help

 
0
  #2
Jul 2nd, 2009
Form1:
  1. using System;
  2. using System.Windows.Forms;
  3.  
  4. namespace daniweb
  5. {
  6. public partial class frm1 : Form
  7. {
  8. public frm1()
  9. {
  10. InitializeComponent();
  11. }
  12.  
  13. public void EnableButton2()
  14. {
  15. button2.Enabled = true;
  16. }
  17.  
  18. private void frm1_Load(object sender, EventArgs e)
  19. {
  20. button1.Enabled = true;
  21. button2.Enabled = false;
  22. }
  23.  
  24. private void button1_Click(object sender, EventArgs e)
  25. {
  26. new frm2().Show();
  27. //this.Hide();
  28. }
  29.  
  30. private void button2_Click(object sender, EventArgs e)
  31. {
  32. //Dont know what you want to do
  33. }
  34. }
  35. }

Form2:
  1. using System;
  2. using System.Windows.Forms;
  3.  
  4. namespace daniweb
  5. {
  6. public partial class frm2 : Form
  7. {
  8. public frm2()
  9. {
  10. InitializeComponent();
  11. }
  12.  
  13. private void button1_Click(object sender, EventArgs e)
  14. {
  15. frm1 f = GetMainForm();
  16. if (f == null)
  17. return;
  18. f.EnableButton2();
  19. //this.Hide();
  20. f.BringToFront();
  21. f.Focus();
  22. }
  23.  
  24. private static frm1 GetMainForm()
  25. {
  26. for (int i1 = 0; i1 < Application.OpenForms.Count; i1++)
  27. {
  28. if (Application.OpenForms[i1] is frm1)
  29. return ((frm1)Application.OpenForms[i1]);
  30. }
  31. return null;
  32. }
  33.  
  34. }
  35. }
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,555
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: 454
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: Check Whether Button Clicked or not - Please Help

 
0
  #3
Jul 3rd, 2009
S2009,

Try to get the solution for same question with single thread. Do not open too many thread?

Scott has explained very well.
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 33
Reputation: Poab9200 is an unknown quantity at this point 
Solved Threads: 1
Poab9200 Poab9200 is offline Offline
Light Poster

Re: Check Whether Button Clicked or not - Please Help

 
0
  #4
Jul 4th, 2009
In the for loop shouldn't you use the != instead of the < than operator?
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