Link to home
Start Free TrialLog in
Avatar of jindalee
jindalee

asked on

How do I programmatically add lines to a Rich Text Box

I have to read the contents of a number of text boxes andmaybe some list boxes (which could potentially hold a large number of items).

Having read them I have to add them to a Rich Text Box for output to a file or printer (or both).

I'm pretty new to Visual BAsic and have learned how to do things with RTBs like change fonts, styles and change the current text.

Can somone please advise me how I write multiple lines to a RTB, i.e. read the contents of a text box, insert it into the next line of a RTB, read the next text box, insert it etc.

(I know how to get the contents of the txt and list boxes, just not how to add them all to the RTB.
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Like this....

    RichTextBox1.Text &= "Your new text" & ControlChars.NewLine

Wayne
Also you can use Append method I am not sure whether it is with text or at object level
Yes, the AppendText method works the same as I posted. Either way, the ControlChars.NewLine constant is needed to add a new line.....

    RichTextBox1.AppendText("Your new text" & ControlChars.NewLine)

Wayne
No I suppose append don't require newline.
SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial