Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to replace the string in my application..

i have used two form. one have my text and second form for find and replace..
using these two form how do i replace string?

just like notepad, how to replace a string?
Posted
Updated 10-May-12 19:22pm
v3
Comments
Sebastian T Xavier 11-May-12 0:26am    
your question is not clear.... what string you are going to replace? Why you have two forms? Is that really necessary....?
Ganesan Senthilvel 11-May-12 0:44am    
Need more clarity
Sandeep Mewara 11-May-12 0:51am    
Not clear. Please elaborate and be specific.
Use the "Improve question" link to edit your question and provide better information.

Exactly how you do this depends on how your find and replace form is to be shown:

1) If it is to be shown only when he asks, and he presses OK to close it and do the search or replace.
2) If it is to be shown continually, and a search happens when he presses an appropriate button, but the search form is still visible.

In the first case, it is easy: Create your search form with two string parameters, and use the ShowDialog method to display it. Processing in your main form will stop until the user presses OK at which point the form will close, and execution will continue in your main form from the statement after the ShowDialog. You can use the properties to access the search and replace strings.

In the second, it's a little harder. You still have the two properties, but the S&R form instance needs to be saved at class level in the main form and the Show method used to display it. The S&R form also needs to create and signal an Event which the main form subscribes. When the event occurs, the main form then reads the two properties, and performs the search. It is also a good idea for the main form to subscribe to the S&R form FormClosing event to kill the saved instance so that a new one cane be created later.
 
Share this answer
 
Comments
VJ Reddy 12-May-12 23:32pm    
Good answer. 5!
Make your find and replace form owner of your main form and then you will able to do what you want.

Have look on this null reference exception while transfering value from one form control to another form control[^]
 
Share this answer
 
v2
Comments
[no name] 11-May-12 1:26am    
i have done it.. two forms are referenced. but i want method to replace.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900