当前位置:首页 > Windows程序 > 正文

ScrollChangedEventArgs e){scHeight = e.ExtentHeight;} WPF r

2024-03-31 Windows程序

在网上没有找到合适的代码,本身写了一段,还有待优化。。。

直接上代码

/// <summary> /// 滚动到某项 /// </summary> /// <param></param> private void ScrollItem(Block sparent) { int count = richTextBox1.Document.ContentStart.GetOffsetToPosition(richTextBox1.Document.ContentEnd);//获取整个textbox中文本的高度 int s1 = richTextBox1.Document.ContentStart.GetOffsetToPosition(sparent.ContentEnd);//项block到文档起点的高度 int s2 = sparent.ContentEnd.GetOffsetToPosition(richTextBox1.Document.ContentEnd);//项block到文档结束点的高度 double h1 = (double)scHeight / count * s1;// (int)((scheight / 100) * s1);//滚动条高度等分,,提取滚动条位置点 richTextBox1.ScrollToVerticalOffset(h1 - 60); } private void richTextBox1_ScrollChanged(object sender, ScrollChangedEventArgs e) { scHeight = e.ExtentHeight; }

WPF richTextBox 滚动到某项

标签:

原文地点:https://www.cnblogs.com/tianciliangen/p/8809794.html

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/33700.html

Jm-杰米博客Jamie
草根站长的技术交流乐园!IT不会不要紧快来好好学习吧!
  • 20786文章总数
  • 7494587访问次数
  • 建站天数
  • 友情链接