tags:

views:

41

answers:

0

When using the following code, I'm getting inconsistent and wrong results from the GetCharacterIndexFromLineIndex method.

var dt = new DispatcherTimer();
dt.Tick += new EventHandler(delegate(object obj,EventArgs e) {
  tb.Text = tb.Text + "a\r\nb\r\nc\r\nd\r\ne\r\nf\r\ng\r\nh\r\ni\r\nj\r\nk\r\n";
  tb.ScrollToLine(10);
  MessageBox.Show(tb.GetCharacterIndexFromLineIndex(10)+" index");
  //shows different numbers every time
});

However when calling ScrollToLine after GetCharacterIndexFromLineIndex I'm getting the correct result every time.

var dt = new DispatcherTimer();
dt.Tick += new EventHandler(delegate(object obj,EventArgs e) {
  tb.Text = tb.Text + "a\r\nb\r\nc\r\nd\r\ne\r\nf\r\ng\r\nh\r\ni\r\nj\r\nk\r\n";
  MessageBox.Show(tb.GetCharacterIndexFromLineIndex(10)+" index");
  tb.ScrollToLine(10);
  //shows always the same correct result
});

I'm using Visual Studio 2008.

It looks like a bug - is there some other explanation?