Notepad? Are you serious? You want to write some text into the the application foreign to yours?
Don't do it.
Really bad idea. It's much more easy to create a desktop application and use a
TextBox
in it. Writing in a certain position of a text box is
pretty bad idea, too.
Don't do it. The text is sequential thing in its nature, don't abuse it. Better use
ListBox
. OK, if you still want to screw up the design and write to a specific line, you have to count line terminators defined as the string
System.Environment.NewLine
. You need to either add new lines or count existing ones, depending on the text already written in the control.
Again, don't do it!
If you still want to screw up the design even more and use real Notepad (what a bad editor, by the way? who needs it?), you can use Windows API
SendInput
to simulate key input. See
http://msdn.microsoft.com/en-us/library/ms646310(v=vs.85).aspx[
^].
Again, don't do it!
Is is really so hard to devise a nice, simple and correct design? What's is your ultimate purpose? I don't think you want what you think you want; more likely you just don't know better ways. If you share what you want to achieve, you can probably get a better advice.
—SA