| | |
Calling Button Operation??
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Sep 2009
Posts: 57
Reputation:
Solved Threads: 0
I have two form.
Form 1 and Form 2
In form 1, i have a few textbox and and combo box. and BTNOk [to save] and BTNCancel[when BTNCancel is click, user are prompt whether to save file if there is changes in entry]
Form 2 is the file where BTNCancel is clicked.
Display:
Do you want to save changes to your setting?
BTNYES,BTNNO, BTNCANCEL.
QUESTION
When I clicked BTNYES in form 2 how can I call BTNOK in form 1 so that it can run the event handler in form 1 BTNOK
another question. any idea of how to do password encryption/decryption
Form 1 and Form 2
In form 1, i have a few textbox and and combo box. and BTNOk [to save] and BTNCancel[when BTNCancel is click, user are prompt whether to save file if there is changes in entry]
Form 2 is the file where BTNCancel is clicked.
Display:
Do you want to save changes to your setting?
BTNYES,BTNNO, BTNCANCEL.
QUESTION
When I clicked BTNYES in form 2 how can I call BTNOK in form 1 so that it can run the event handler in form 1 BTNOK
another question. any idea of how to do password encryption/decryption
•
•
Join Date: Oct 2008
Posts: 56
Reputation:
Solved Threads: 1
•
•
•
•
I have two form.
Form 1 and Form 2
In form 1, i have a few textbox and and combo box. and BTNOk [to save] and BTNCancel[when BTNCancel is click, user are prompt whether to save file if there is changes in entry]
Form 2 is the file where BTNCancel is clicked.
Display:
Do you want to save changes to your setting?
BTNYES,BTNNO, BTNCANCEL.
QUESTION
When I clicked BTNYES in form 2 how can I call BTNOK in form 1 so that it can run the event handler in form 1 BTNOK
another question. any idea of how to do password encryption/decryption
You should set the BTNOK event handler in form1's class to public instead of private, this will enable you to call it from form2's class.
Then the code in form 2:
private void BTNYES (object sender, Eventargs e)
Form1 form1 = new Form1();
form1.BTNOK(sender, e);
This should do it, but uses too much resources for the purpose, I think.
•
•
Join Date: Jul 2009
Posts: 914
Reputation:
Solved Threads: 146
•
•
•
•
I have two form.
Form 1 and Form 2
In form 1, i have a few textbox and and combo box. and BTNOk [to save] and BTNCancel[when BTNCancel is click, user are prompt whether to save file if there is changes in entry]
Form 2 is the file where BTNCancel is clicked.
Display:
Do you want to save changes to your setting?
BTNYES,BTNNO, BTNCANCEL.
QUESTION
When I clicked BTNYES in form 2 how can I call BTNOK in form 1 so that it can run the event handler in form 1 BTNOK
another question. any idea of how to do password encryption/decryption
C# Syntax (Toggle Plain Text)
// in form1 where calling form2 Form form2 = new Form(); DialogResult result = form2.ShowDialog(); if (result == DialogResult.OK) // or whatever result you want to return { //call your handler to save or whatever } // inside form2's button handler: this.DialogResult = DialogResult.OK; // will be returned from form2.ShowDialog()
•
•
Join Date: May 2009
Posts: 111
Reputation:
Solved Threads: 11
For password encryption you can use SHA-1. It's actually hashing not encryption, but I think for your purposes it would work fine...
c# Syntax (Toggle Plain Text)
public static string EncryptSHA1(string text, Encoding enc) { byte[] buffer = enc.GetBytes(text); SHA1CryptoServiceProvider cryptoTransformSHA1 = new SHA1CryptoServiceProvider(); string hash = BitConverter.ToString( cryptoTransformSHA1.ComputeHash(buffer)).Replace("-", ""); return hash; }
•
•
Join Date: Sep 2009
Posts: 57
Reputation:
Solved Threads: 0
•
•
•
•
For password encryption you can use SHA-1. It's actually hashing not encryption, but I think for your purposes it would work fine...
c# Syntax (Toggle Plain Text)
public static string EncryptSHA1(string text, Encoding enc) { byte[] buffer = enc.GetBytes(text); SHA1CryptoServiceProvider cryptoTransformSHA1 = new SHA1CryptoServiceProvider(); string hash = BitConverter.ToString( cryptoTransformSHA1.ComputeHash(buffer)).Replace("-", ""); return hash; }
i only want to encrypt the data in textbox that is previously entered and store in textfile. and where do i put the code in exact. =X I'm quite blur .
•
•
Join Date: Sep 2009
Posts: 57
Reputation:
Solved Threads: 0
•
•
•
•
Hello!
You should set the BTNOK event handler in form1's class to public instead of private, this will enable you to call it from form2's class.
Then the code in form 2:
private void BTNYES (object sender, Eventargs e) Form1 form1 = new Form1(); form1.BTNOK(sender, e);
This should do it, but uses too much resources for the purpose, I think.
If all that form2 does is display the question and allow the user to click one of the buttons then you can use the MessageBox class to do the same thing:
C# Syntax (Toggle Plain Text)
DialogResult result = MessageBox.Show("Do you want to save changes to your setting?", "Save before exit?", MessageBoxButtons.YesNoCancel); if (result == DialogResult.Yes) { //save changes }
![]() |
Similar Threads
- Call a button click event under another sub procedure (VB.NET)
- Calling button-click events from different classes (Python)
- Trojan Desktophijack.B and others (Viruses, Spyware and other Nasties)
- Help With A Timer And Stopping It. (C++)
Other Threads in the C# Forum
- Previous Thread: need to get a running process
- Next Thread: How to click on button on web page
| Thread Tools | Search this Thread |
add array basic blackmail block browser buttons c# c++ cellphone challenge click compression cookies crack crime data decryption dell ect ediscovery email encryption enterprise fade firefox forms ftp government hardware java kioti16 kmip laptop london microsoft mobile news opacity opensource panel password php problem program programming protection radio rsa security size softwaredevelopment string sun survey taxi textbox transparency user virus webmail word






