On Mon, 11 Jun 2007 13:50:00 -0700, Ray Mitchell
True. Sorry, I didn't realize you couldn't use that without some effort..
I haven't actually upgraded a 2.0 to 3.0 installation, so while I believe
there should be a relatively simple way to allow .NET 3.0 development in
your existing VS 2005 installation, I don't know the specifics. I
_suspect_ that there's a .NET 3.0 SDK you can install that will do the
right things to enable that.
However, it's not difficult to implement yourself, if you don't want to
bother with .NET 3.0. You can simply write your own version of that
method, that takes the Text or Lines property of the text box and scans
through it for the number of line breaks corresponding to the "lineNo"
value. For example (warning, code not even compiled, never mind
tested...but this should give you the basic idea):
int GetCharacterIndexFromLineIndex(int lineNo, string str)
if (lineNo-- > 0)
int ichNewLine = str.IndexOf(Environment.NewLine);
while (ichNewLine != -1 && lineNo-- > 0)
ichNewLine = str.IndexOf(Environment.NewLine, ichNewLine
if (ichNewLine + Environment.NewLine.Length >= str.Length)
ichNewLine = -1;
or alternatively (depending on whether you want to pass the Text property
or Lines property):
int GetCharacterIndexFromLineIndex(int lineNo, string rgstrLines)
int ichNewLine = 0;
for (int ilineCur = 0; ilineCur < rgstrLines.Length && lineNo > 0;
ichNewLine += rgstrLines[ilineCur].Length
return (lineNo > 0) ? -1 : ichNewLine;
Hope that helps.