public void AppendText(string s) { if (ShowLineCount) { s = lc + ":" + s; lc++; } TextBox.AppendText(s); TextBox.ScrollToCaret(); UpdateScrollBar(); }
private void ScrollToBar() // from the scrollbar, scroll first line to value { int scrollvalue = ScrollBar.Value; if (Environment.OSVersion.Platform != PlatformID.Win32NT) { int line = scrollvalue + (lastscrollto <= scrollvalue ? visiblelines - 1 : 0); int index = TextBox.GetFirstCharIndexFromLine(line); // MONO does not do EM.LiNESCROLL - this is the best we can do lastscrollto = scrollvalue; //System.Diagnostics.Debug.WriteLine("Scroll Bar:" + scrollvalue + " vl " + visiblelines + " goto " + line); TextBox.Select(index, 0); TextBox.ScrollToCaret(); } else { int firstVisibleLine = unchecked ((int)(long)TextBox.SendMessage(EM.GETFIRSTVISIBLELINE, IntPtr.Zero, IntPtr.Zero)); int delta = scrollvalue - firstVisibleLine; //Console.WriteLine("Scroll Bar:" + scrollvalue + " FVL: " + firstVisibleLine + " delta " + delta); if (delta != 0) { TextBox.SendMessage(EM.LINESCROLL, IntPtr.Zero, (IntPtr)(delta)); } } }