943,837 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 4481
  • C# RSS
You are currently viewing page 1 of this multi-page discussion thread
Sep 16th, 2009
0

Detected Changes in Combo Box & Text Box

Expand Post »
Hi ALL I'm having trouble figuring out..

I have one BTNCANCEL here and cmb1,cmb2,cm3, tb1,tb2.

How do i program so that it detect changes in cmb1,cmb2,cm3, tb1,tb2 and then when i click BTN cancel it will PROMPT to save yes/no [which i have already programed] if there is a change in either one of this[cmb1,cmb2,cm3, tb1,tb2] in runtime. and the program will close if there is no changes.

with reference to stored value in text file data.
[when I debug, the value stored in text file is displayed in cmb1,cmb2,cmb3,tb1,tb2]

So i would like to know how to do a program to BTNCANCEL_Click
that when it detected changes:

C# Syntax (Toggle Plain Text)
  1. if (detect change)
  2. {
  3. using (SaveSetting settings = new SaveSetting())
  4. {
  5. //read properties from dialogue
  6. //when dialogue is yes it will run save and exit application
  7. if (settings.ShowDialog() == DialogResult.Yes)
  8. {
  9. save();
  10. Application.Exit();
  11. }
  12. }
  13.  
  14. }
  15. else
  16. {
  17. Close();
  18. }
  19. }
Similar Threads
Reputation Points: 1
Solved Threads: 0
Junior Poster in Training
facadie is offline Offline
57 posts
since Sep 2009
Sep 16th, 2009
0

Re: Detected Changes in Combo Box & Text Box

There's events detect that
TextBox | TextChanged
ComboBox | SelectedIndexChanged
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 16th, 2009
0

Re: Detected Changes in Combo Box & Text Box

Push initial values to an array,
C# Syntax (Toggle Plain Text)
  1. ....
  2. arr[0]=cmb1.Text;
  3. ....
Detect changes,
C# Syntax (Toggle Plain Text)
  1. if(ar[0]!=cmd1.Text ......) {
  2. // statements
  3. }
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Sep 16th, 2009
0

Re: Detected Changes in Combo Box & Text Box

Click to Expand / Collapse  Quote originally posted by facadie ...
Hi ALL I'm having trouble figuring out..

I have one BTNCANCEL here and cmb1,cmb2,cm3, tb1,tb2.

How do i program so that it detect changes in cmb1,cmb2,cm3, tb1,tb2 and then when i click BTN cancel it will PROMPT to save yes/no [which i have already programed] if there is a change in either one of this[cmb1,cmb2,cm3, tb1,tb2] in runtime. and the program will close if there is no changes.

with reference to stored value in text file data.
[when I debug, the value stored in text file is displayed in cmb1,cmb2,cmb3,tb1,tb2]

So i would like to know how to do a program to BTNCANCEL_Click
that when it detected changes:

C# Syntax (Toggle Plain Text)
  1. if (detect change)
  2. {
  3. using (SaveSetting settings = new SaveSetting())
  4. {
  5. //read properties from dialogue
  6. //when dialogue is yes it will run save and exit application
  7. if (settings.ShowDialog() == DialogResult.Yes)
  8. {
  9. save();
  10. Application.Exit();
  11. }
  12. }
  13.  
  14. }
  15. else
  16. {
  17. Close();
  18. }
  19. }
i found an easier way but does anyone know how to detect combo box selected item change??

C# Syntax (Toggle Plain Text)
  1. //if any of the textbox is modified
  2. if ((TBCurrentP.Modified == true) || (TBImageL.Modified == true) || (TBDatabaseL.Modified == true))
  3. {
  4. if (TBNewP.Text != TBConfirmP.Text)
  5. {
  6. MessageBox.Show("The two passwords that you entered do not match.");
  7. }
  8.  
  9. else
  10. {
  11. //calling method save
  12. save();
  13. this.Close();
  14. }
  15. }
  16.  
  17. else
  18. Close();
  19. }
  20. }
[/QUOTE]
Reputation Points: 1
Solved Threads: 0
Junior Poster in Training
facadie is offline Offline
57 posts
since Sep 2009
Sep 17th, 2009
0

Re: Detected Changes in Combo Box & Text Box

LOL! did you read my reply??!!
Quote ...
There's events detect that
TextBox | TextChanged
ComboBox | SelectedIndexChanged
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 17th, 2009
0

Re: Detected Changes in Combo Box & Text Box

LOL! did you read my reply??!!
haas i did. but i dun get it? actually my programming sucks pretty much if not for school work=p sorry for that=X
Reputation Points: 1
Solved Threads: 0
Junior Poster in Training
facadie is offline Offline
57 posts
since Sep 2009
Sep 17th, 2009
0

Re: Detected Changes in Combo Box & Text Box

On the ComboBox double click, VS created a handler for index changed event copy and paste your code, and solve any error if exists..
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 17th, 2009
0

Re: Detected Changes in Combo Box & Text Box

This is what the event wiring for combobox selection change should look like in case you don't use VS designer:
C# Syntax (Toggle Plain Text)
  1. // in form intialization:
  2. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  3.  
  4. // then, just create this method for your form:
  5. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  6. {
  7. // to retrieve it's index:
  8. int index = comboBox1.SelectedIndex;
  9. /// if your item is text, otherwise cast to proper type:
  10. string text = (string)comboBox1.SelectedItem;
  11. }
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009
Sep 18th, 2009
0

Re: Detected Changes in Combo Box & Text Box

LOL! did you read my reply??!!
OO but the function i want on it actually happen only when i click BTNOK?

as in when i click BTNOK, it detect changes and save else close no saving etc.

now what i have done is i detected that the text box is changed and it will save. but i duno how to go about doing that for just combo box.

cos if i use the event handler i duno how do i go about linking it with the btn?
Reputation Points: 1
Solved Threads: 0
Junior Poster in Training
facadie is offline Offline
57 posts
since Sep 2009
Sep 18th, 2009
0

Re: Detected Changes in Combo Box & Text Box

Click to Expand / Collapse  Quote originally posted by DdoubleD ...
This is what the event wiring for combobox selection change should look like in case you don't use VS designer:
C# Syntax (Toggle Plain Text)
  1. // in form intialization:
  2. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  3.  
  4. // then, just create this method for your form:
  5. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  6. {
  7. // to retrieve it's index:
  8. int index = comboBox1.SelectedIndex;
  9. /// if your item is text, otherwise cast to proper type:
  10. string text = (string)comboBox1.SelectedItem;
  11. }
hello=) i think it run withins the form?
but how do i make it so like:

when i click BTNOK it will run the program which will a check if any textbox or any combo boxes[selecteditem] have change as compare to the data store. then it will run save program.

so it's like doing a check when BTN OK is click.
Reputation Points: 1
Solved Threads: 0
Junior Poster in Training
facadie is offline Offline
57 posts
since Sep 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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: Validation
Next Thread in C# Forum Timeline: Design Report using ReportViewer Wizard in Visual Studio 2005





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


Follow us on Twitter


© 2011 DaniWeb® LLC