yoni2
yoni2

Reputation: 111

C# textbox problem, how to cut the value of the textbox

Hi i am writing an app in c# using windows form, In this form i have a text box that get input form a user, And then I need to to some changes on it. The problem is that the value in the text box is a long string with "\r\n" as a separator between lines. How can I get the text in the text box, I need that every line will be a cell a so I can get a string[].

thanks

Upvotes: 0

Views: 689

Answers (3)

digEmAll
digEmAll

Reputation: 57220

You could use the .Lines property of TextBox control, that already contains the text splitted in lines.

Upvotes: 0

Ofershap
Ofershap

Reputation: 727

Try using method Split("\r\n") on the string returned from Textbox.Text

Upvotes: 0

stuartmclark
stuartmclark

Reputation: 1243

You could do:

string temp = textBox1.Text;
string[] strList = temp.Split("\\r\\n");

Upvotes: 1

Related Questions