This is a migrated thread and some comments may be shown as answers.

RadTextbox multiline split

2 Answers 261 Views
Input
This is a migrated thread and some comments may be shown as answers.
Johnathan
Top achievements
Rank 1
Johnathan asked on 19 Jul 2012, 03:43 PM
Hello,

I'm attempting to work with a multi-line RadTextbox and split the text contained in it into a string array based on which "line" the text is on. So, it would look something like this:

Text1
Text2
Text3
....

So, Text1, Text2, and Text3 would be each their own array item. The user is required to hit enter after each line entry, so I'm attempted to split the textbox based on each enter key entry. I attempted the following splits, but none of these worked:

RadTextbox.Text.Split("\r\n")
RadTextbox.Text.Split(vbCrLf)
RadTextbox.Text.Split(" ")
RadTextbox.Text.Split(CChar(" "))

Any help on this would be greatly appreciated.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Jul 2012, 05:10 AM
Hi Johnathan,

Try the following code snippet to achieve your scenario.

C#:
protected void Button_Click(object sender, EventArgs e)
{
 string[] split = RadTextBox1.Text.Split(new char[] { '\n' });
}

Hope this helps.

Thanks,
princy.
0
Johnathan
Top achievements
Rank 1
answered on 21 Jul 2012, 03:22 PM
Hey Princy,

I was able to take the code you sent me and found an equivalent version in Visual Basic that worked. Thanks for you help!

Note: Here's the code that worked

Radtextbox1.Text.Split(ControlChars.Lf)

Thanks,

Johnathan
Tags
Input
Asked by
Johnathan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Johnathan
Top achievements
Rank 1
Share this question
or