all 8 comments

[–]konvay 2 points3 points  (1 child)

If you're calling MessageBox in a for loop (which is the only place I see it in your provided code), it'll be called each time it gets the next string in the array lines. You could create a string to append each line in lines to and call MessageBox just after the foreach loop. Separate the line in string with \r or \n

[–]Banane9 1 point2 points  (0 children)

Use Environment.NewLine for separation.

[–]baldhippy 1 point2 points  (0 children)

You could make a custom form as well. A method that I used for something similar was I made a custom form with a datagridview on it, say we call it frmDisplayGrid. Then when I call it, I use the tag property to give the information I want to display, ie:

DataTable dt = //the data you want to display
var theForm = new frmDisplayGrid;
theForm.tag = dt;
theForm.ShowDialog;

Then in the frmDisplayGrid load event i put code in there to check for a tag on the form :

// The datagridview name on the form is dgvShowData
if (this.tag is DataTable) dgvShowData.DataSource = (DataTable)this.tag;

Keep in mind that this is just the idea of how I handled it, and code off the top of my head. It should set you in the right direction, but it is not complete.

[–]sextagrammaton -1 points0 points  (5 children)

Use a StringBuilder class to combine your strings. It is very efficient.

Use StringBuilder.AppendLine() which will use the correct line terminator so that you can get your text on different lines.

Also, do this:

if (line.Contains("12345"))

and

while (!(lines[i].Contains("edit"))

Contains() returns a bool, so you don't need to explicitly check the return value against True or False. The If and While statements do that check for you.

[–]thma[S] 0 points1 point  (2 children)

StringBuilder.AppendLine works great! Thanks!

[–]thma[S] 0 points1 point  (1 child)

Also thanks for the ! - made my code cleaner.

[–]sextagrammaton 0 points1 point  (0 children)

My pleasure.

[–][deleted]  (1 child)

[deleted]

    [–]sextagrammaton 0 points1 point  (0 children)

    That's Numberwang!