Inserting strings in a multiline TextBox control

  • Thread starter Thread starter Peter Nagel
  • Start date Start date
P

Peter Nagel

I would like to insert some strings in a multiline TextBox. At the time of
inserting the TextBox already contains some strings each in a separate line.
The new lines should be inserted somewhere in the middle of the existing
lines moving some line to higher indices of the Lines property.

What would be a good solution for my little problem?

Greetings from Germany,

Peter
 
Peter,

You can use the Lines property on the TextBox to do this for you. Quite
simply, get the array returned by the Lines property. Create a new array
that has your new line inserted, and then set the Lines property to that
array.

Hope this helps.
 
Hello Nicholas,

thank you for your answer supporting my first steps in C# after some years
experience with Borland's Delphi.

Peter
 
Nicholas said:
Peter,

You can use the Lines property on the TextBox to do this for you.
Quite simply, get the array returned by the Lines property. Create a
new array that has your new line inserted, and then set the Lines
property to that array.

Is that the (only) way to do it?
It seems overly complicated, compared to e.g. Items.add.

--
Thomas Due
Posted with XanaNews version 1.16.3.1

"Insanity in individuals is something rare - but in groups, parties,
nations and epochs, it is the rule."
-- Friedrich Nietzsche
 
Hi,
This is a silly question but how do I connect to a specific database using
DMO.
SQLDMO.SQLServerClass srv;

srv = new SQLServerClass ();

srv.LoginSecure =true;

srv.Connect ("stgnyc002", "user", "psd");

SQLDMO.Database db = srv.Databases("pubs"); // This doesn't work.

Thanks in advance for any help.

Asim.
 
Hi Thomas

You can always append to the text property Using something like this
Text1.Text += String.Format("{0}{1}","You Text Here",Environment.NewLine) ;

Depending how and how much you want to add to the text box you can use the
StringBuilder to (populate and add a newline) to your text and then use the
same method above.

However, I personally think the Lines property is a cleaner and better
approach :-)

Henk
 
Back
Top