|
-
Oct 20th, 2011, 07:14 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] How populate a richtextbox from a textbox
I have a richtextbox in the form1 and I textbox in the form2 with a text example "hi, have a nice days" so I need to save this text into the richtextbox. So I need code in a button in the form2 for to save the text into the richtextbox in the form1.
-
Oct 20th, 2011, 07:37 PM
#2
Re: How populate a richtextbox from a textbox
I very much doubt that you do need such code. What is the relationship between the two forms? I'm guessing that Form1 creates Form2, correct? Are you displaying the second form modally or non-modally, i.e. with ShowDialog or Show? Do you want to transfer the text back to the first form when the second closes?
-
Oct 20th, 2011, 08:19 PM
#3
Thread Starter
Hyperactive Member
Re: How populate a richtextbox from a textbox
I want to use the form two only for populate the richtextbox, for example in the form 1 there is a button "add text" when I make click on this button appear the form two with a textbox so I write or paste a text in this textbox and click ok(other button) for populate the richtextbox.
 Originally Posted by jmcilhinney
I very much doubt that you do need such code. What is the relationship between the two forms? I'm guessing that Form1 creates Form2, correct? Are you displaying the second form modally or non-modally, i.e. with ShowDialog or Show? Do you want to transfer the text back to the first form when the second closes?
-
Oct 20th, 2011, 08:41 PM
#4
Re: How populate a richtextbox from a textbox
Is it not simpler to just type directly into the RichTextBox on Form1 rather than open a second Form, type into a TextBox on that Form then have it transferred to the original Form's RichTextBox?
-
Oct 20th, 2011, 08:53 PM
#5
Thread Starter
Hyperactive Member
Re: How populate a richtextbox from a textbox
 Originally Posted by Inferrd
Is it not simpler to just type directly into the RichTextBox on Form1 rather than open a second Form, type into a TextBox on that Form then have it transferred to the original Form's RichTextBox?
No because I am using a spintax code so I only know work with this with a textbox.
example I have in the textbox something like {hello|hi} {albert|george|lois} have a good {nite|weekend|day}
so each time when I make click the sentence change like :
1-Hello albert have a good nite
2-hi george have a good weekend
etc.
-
Oct 20th, 2011, 08:55 PM
#6
Re: How populate a richtextbox from a textbox
 Originally Posted by romanos8
I want to use the form two only for populate the richtextbox, for example in the form 1 there is a button "add text" when I make click on this button appear the form two with a textbox so I write or paste a text in this textbox and click ok(other button) for populate the richtextbox.
The it is exactly as I thought. The second form shouldn't know anything about the first form. Dialogues should almost always be independent of their caller.
In this case, your OK button on the second form should be setting the form's DialogResult property to OK and that is ALL. You would also add a property (probably a ReadOnly property) that exposes the Text of the TextBox. In the first form, you display the dialogue by calling ShowDialog and then test the result. If it's OK then you get that property value and add it to your RTB.
-
Oct 20th, 2011, 10:55 PM
#7
Thread Starter
Hyperactive Member
Re: How populate a richtextbox from a textbox
Thank you very much jmcilhinney
Last edited by romanos8; Oct 20th, 2011 at 11:56 PM.
-
Oct 20th, 2011, 11:26 PM
#8
Re: How populate a richtextbox from a textbox
 Originally Posted by romanos8
Thank you very much Jmcihieey
If you can't spell my name, just copy and paste it from one of my posts.
-
Oct 20th, 2011, 11:55 PM
#9
Thread Starter
Hyperactive Member
Re: How populate a richtextbox from a textbox
 Originally Posted by romanos8
Thank you very much jmcilhinney
fixed!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|