Click here to Skip to main content
15,846,211 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to arrange a text.
I have 2 textbox the first I enter a random text and the second to display the but in a more better way

What I have tried:

I make 2 textboxes in the 1st one I write a random text and textbox2 receives text1
the question how the code can does the arrangement when it finds a specific word it wraps the line with that the word is at the front of the new line each time that he finds
Updated 25-Apr-22 7:07am
Richard MacCutchan 25-Apr-22 11:19am    
Very interesting, but do you have a question?

1 solution

If you set the TextBox as Multiline, then it supports a Lines property: an array of strings, with each string element displayed on a new line: TextBoxBase.Lines Property (System.Windows.Forms) | Microsoft Docs[^]

So all you need to do is find the index of each match start offset in your input, and copy each "section" into a new string in your array.
I'd start with a List as you don't know how many elements there will be, then convert it to an array using ToArray to set the Lines property of the output TextBox.
Share this answer

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