943,718 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 3189
  • C# RSS
Jul 2nd, 2009
0

Check Whether Button Clicked or not - Please Help

Expand Post »
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!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
S2009 is offline Offline
67 posts
since Jun 2009
Jul 2nd, 2009
0

Re: Check Whether Button Clicked or not - Please Help

Form1:
c# Syntax (Toggle Plain Text)
  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:
c# Syntax (Toggle Plain Text)
  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. }
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: Check Whether Button Clicked or not - Please Help

S2009,

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

Scott has explained very well.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Jul 4th, 2009
0

Re: Check Whether Button Clicked or not - Please Help

In the for loop shouldn't you use the != instead of the < than operator?
Reputation Points: 16
Solved Threads: 1
Light Poster
Poab9200 is offline Offline
35 posts
since Aug 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: Lines per Day
Next Thread in C# Forum Timeline: Use of List<int[]>





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


Follow us on Twitter


© 2011 DaniWeb® LLC