Results 1 to 9 of 9

Thread: [RESOLVED] How populate a richtextbox from a textbox

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2011
    Posts
    294

    Resolved [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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2011
    Posts
    294

    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.
    Quote Originally Posted by jmcilhinney View Post
    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?

  4. #4
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    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?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2011
    Posts
    294

    Re: How populate a richtextbox from a textbox

    Quote Originally Posted by Inferrd View Post
    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.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How populate a richtextbox from a textbox

    Quote Originally Posted by romanos8 View Post
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2011
    Posts
    294

    Re: How populate a richtextbox from a textbox

    Thank you very much jmcilhinney
    Last edited by romanos8; Oct 20th, 2011 at 11:56 PM.

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How populate a richtextbox from a textbox

    Quote Originally Posted by romanos8 View Post
    Thank you very much Jmcihieey
    If you can't spell my name, just copy and paste it from one of my posts.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2011
    Posts
    294

    Re: How populate a richtextbox from a textbox

    Quote Originally Posted by romanos8 View Post
    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
  •  



Click Here to Expand Forum to Full Width