Detected Changes in Combo Box & Text Box

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Sep 2009
Posts: 54
Reputation: facadie has a little shameless behaviour in the past 
Solved Threads: 0
facadie facadie is offline Offline
Junior Poster in Training

Detected Changes in Combo Box & Text Box

 
0
  #1
Sep 16th, 2009
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:

  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. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Detected Changes in Combo Box & Text Box

 
0
  #2
Sep 16th, 2009
There's events detect that
TextBox | TextChanged
ComboBox | SelectedIndexChanged
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,590
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: 458
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: Detected Changes in Combo Box & Text Box

 
0
  #3
Sep 16th, 2009
Push initial values to an array,
  1. ....
  2. arr[0]=cmb1.Text;
  3. ....
Detect changes,
  1. if(ar[0]!=cmd1.Text ......) {
  2. // statements
  3. }
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 54
Reputation: facadie has a little shameless behaviour in the past 
Solved Threads: 0
facadie facadie is offline Offline
Junior Poster in Training

Re: Detected Changes in Combo Box & Text Box

 
0
  #4
Sep 16th, 2009
Originally Posted by facadie View 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:

  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??

  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]
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Detected Changes in Combo Box & Text Box

 
0
  #5
Sep 17th, 2009
LOL! did you read my reply??!!
There's events detect that
TextBox | TextChanged
ComboBox | SelectedIndexChanged
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 54
Reputation: facadie has a little shameless behaviour in the past 
Solved Threads: 0
facadie facadie is offline Offline
Junior Poster in Training

Re: Detected Changes in Combo Box & Text Box

 
0
  #6
Sep 17th, 2009
Originally Posted by Ramy Mahrous View Post
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Detected Changes in Combo Box & Text Box

 
0
  #7
Sep 17th, 2009
On the ComboBox double click, VS created a handler for index changed event copy and paste your code, and solve any error if exists..
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 886
Reputation: DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough 
Solved Threads: 140
DdoubleD DdoubleD is offline Offline
Practically a Posting Shark

Re: Detected Changes in Combo Box & Text Box

 
0
  #8
Sep 17th, 2009
This is what the event wiring for combobox selection change should look like in case you don't use VS designer:
  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. }
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 54
Reputation: facadie has a little shameless behaviour in the past 
Solved Threads: 0
facadie facadie is offline Offline
Junior Poster in Training

Re: Detected Changes in Combo Box & Text Box

 
0
  #9
Sep 18th, 2009
Originally Posted by Ramy Mahrous View Post
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?
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 54
Reputation: facadie has a little shameless behaviour in the past 
Solved Threads: 0
facadie facadie is offline Offline
Junior Poster in Training

Re: Detected Changes in Combo Box & Text Box

 
0
  #10
Sep 18th, 2009
Originally Posted by DdoubleD View Post
This is what the event wiring for combobox selection change should look like in case you don't use VS designer:
  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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
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