c# - How can I replace text in RichTextBox form another form? -
so have richtextbox called richtextbox1
, in form named xmleditor
want able rename chosen word in parts of rich text box want. (like find , replace in notepad).
but want use form called find
(it looks find & replace in notepad) have functions replace words in richtextbox1
in xmleditor
.
the form named find
has 2 textboxes , 1 button. first textbox named textbox1
used choose text replace while textbox3
text replaced with. , button button3
replace text while clicked.
how can replace text in richtextbox
form? how can these forms?
void button3_click(object sender, eventargs e) { xmleditor xmle = new xmleditor(); xmle.richtextbox1.text = xmle.richtextbox1.text.replace(textbox1.text, textbox3.text); }
one thing can pass xmleditor form parameter when constructing find, , have public xmleditor method can used interaction.
interface ifindandreplace { void replace(string s); } public class xmleditor : ifindandreplace { ... public void showfindandreplaceform() { find findform = new find(this); } public void replace(string s) { //replace method here } } public class find { ifindandreplace parent; public find(ifindandreplace parent) { this.parent = parent; } public replace(string s) { parent.replace(s); //this call replace on parent form. } }
edited use interfaces :)
Comments
Post a Comment