TextBox. GetLineIndexFromCharacterIndex returns -1 when passing in large text

  • Thread starter Thread starter moondaddy
  • Start date Start date
M

moondaddy

Guest
The sample code below calls the GetLineIndexFromCharacterIndex method on the TextBox and it returns -1 when passing in text 55,000 or larger. Is this a bug and is there a work-around for this?

public MainWindow()
{
InitializeComponent();
string text = "";
string path = "problematicFile.txt";

// This text is added only once to the file.
if (File.Exists(path))
{
text = System.IO.File.ReadAllText(path);
}
textBox.Text = text;
var chararcter1 = textBox.Text[56218];
var chararcter2 = textBox.Text[56325];
int index1 = textBox.GetLineIndexFromCharacterIndex(56218);
int index2 = textBox.GetLineIndexFromCharacterIndex(56325);
}


1567747.png

Thank You!

Continue reading...
 

Similar threads

Back
Top