gpt4 book ai didi

c# - WPF 的 TextBox 中的 ScrollToCaret 在哪里?

转载 作者:太空狗 更新时间:2023-10-29 23:09:02 25 4
gpt4 key购买 nike

我找不到那个函数。基本上我有一个多行文本框,当我执行搜索时,我会突出显示结果。但是,如果结果不在 View 中,我将不得不手动向下滚动,直到找到突出显示的结果,这超出了“查找”功能的目的。

我不想使用 RichTextBox,因为我遇到了一些性能问题。

最佳答案

你可以使用 GetLineIndexFromCharacterIndex结合ScrollToLine :

var selectionStart = x;
var selectionLength = y;
textBox.Select(selectionStart, selectionLength);
textBox.ScrollToLine(textBox.GetLineIndexFromCharacterIndex(textBox.SelectionStart));

关于c# - WPF 的 TextBox 中的 ScrollToCaret 在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13621549/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com