| | |
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:
Solved Threads: 0
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:
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)
if (detect change) { using (SaveSetting settings = new SaveSetting()) { //read properties from dialogue //when dialogue is yes it will run save and exit application if (settings.ShowDialog() == DialogResult.Yes) { save(); Application.Exit(); } } } else { Close(); } }
There's events detect that
TextBox | TextChanged
ComboBox | SelectedIndexChanged
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
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Push initial values to an array,
Detect changes,
C# Syntax (Toggle Plain Text)
.... arr[0]=cmb1.Text; ....
C# Syntax (Toggle Plain Text)
if(ar[0]!=cmd1.Text ......) { // statements }
Failure is not fatal, but failure to change might be. - John Wooden
•
•
Join Date: Sep 2009
Posts: 54
Reputation:
Solved Threads: 0
•
•
•
•
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)
if (detect change) { using (SaveSetting settings = new SaveSetting()) { //read properties from dialogue //when dialogue is yes it will run save and exit application if (settings.ShowDialog() == DialogResult.Yes) { save(); Application.Exit(); } } } else { Close(); } }
C# Syntax (Toggle Plain Text)
//if any of the textbox is modified if ((TBCurrentP.Modified == true) || (TBImageL.Modified == true) || (TBDatabaseL.Modified == true)) { if (TBNewP.Text != TBConfirmP.Text) { MessageBox.Show("The two passwords that you entered do not match."); } else { //calling method save save(); this.Close(); } } else Close(); } }
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
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
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
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Jul 2009
Posts: 886
Reputation:
Solved Threads: 140
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)
// in form intialization: this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); // then, just create this method for your form: private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { // to retrieve it's index: int index = comboBox1.SelectedIndex; /// if your item is text, otherwise cast to proper type: string text = (string)comboBox1.SelectedItem; }
•
•
Join Date: Sep 2009
Posts: 54
Reputation:
Solved Threads: 0
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?
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?
•
•
Join Date: Sep 2009
Posts: 54
Reputation:
Solved Threads: 0
•
•
•
•
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)
// in form intialization: this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); // then, just create this method for your form: private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { // to retrieve it's index: int index = comboBox1.SelectedIndex; /// if your item is text, otherwise cast to proper type: string text = (string)comboBox1.SelectedItem; }
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.
![]() |
Similar Threads
- on combo item selection enable /disable text box (PHP)
- Showing corresponding combobox data in a text box (Visual Basic 4 / 5 / 6)
- Text Box populated by Combo Box (Visual Basic 4 / 5 / 6)
- How to fix Lenght of Text Box (C#)
- How to open .txt file and display in text box? (VB.NET)
- Showing result in vb6 to crystal rpeort 10's text box (Visual Basic 4 / 5 / 6)
- fetch value of text box outside thread (C#)
- Recordset value in text box (ASP)
- Select Box populates text field (JavaScript / DHTML / AJAX)
- cdo using combo box in my form (ASP)
Other Threads in the C# Forum
- Previous Thread: Validation
- Next Thread: Design Report using ReportViewer Wizard in Visual Studio 2005
| Thread Tools | Search this Thread |
.net access activedirectory ado.net algorithm array barchart bitmap box broadcast c# check checkbox client combobox contorl control conversion csharp custom database datagrid datagridview dataset datetime degrees deployment development disabled displayingopenforms draganddrop drawing editing editor encryption enum excel file foreach form format forms ftp function gdi+ httpwebrequest i18n image imageprocessing index index-error input install java label list listbox mandelbrot math mathematics mouseclick mysql operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remoting richtextbox rows server setup sleep socket sql statistics stream string table text textbox thread time timer update user usercontrol validation visualstudio webbrowser windows winforms wpf xml






