C# Word:SyncScrollingSideBySide和ScrollingToView
Word加载项的一个功能是并排显示两个文档窗口。用户可以双击左侧文档中的段落,将右侧文档中的关联段落滚动到视图中。执行此操作时,如果在双击之前启用了同步滚动,则希望重新启用同步滚动。我们正在做这样的事情:C# Word:SyncScrollingSideBySide和ScrollingToView,c#,.net,ms-word,vsto,ms-office,C#,.net,Ms Word,Vsto,Ms Office,Word加载项的一个功能是并排显示两个文档窗口。用户可以双击左侧文档中的段落,将右侧文档中的关联段落滚动到视图中。执行此操作时,如果在双击之前启用了同步滚动,则希望重新启用同步滚动。我们正在做这样的事情: private void LineUpParagraphs() { // Unlock the views so we can scroll them independently. bool wasSyncEnabled = this.originalDocument.Docu
private void LineUpParagraphs()
{
// Unlock the views so we can scroll them independently.
bool wasSyncEnabled = this.originalDocument.Document.Windows.SyncScrollingSideBySide;
this.originalDocument.Document.Windows.SyncScrollingSideBySide = false;
// Scroll corresponding original paragraph into view.
this.originalDocument.Document.Windows[1].ScrollIntoView(
this.CurrentOriginalParagraph.Range);
// Re-enable synchronous scrolling if it was enabled before.
if (wasSyncEnabled)
{
this.originalDocument.Document.Windows.SyncScrollingSideBySide = true;
}
}
执行此操作后,所需范围将显示在原始文档(应用程序的右侧)中,但只要滚动任一窗口,右侧窗口将跳回其原始位置。
我们尝试过但不起作用的事情:
- 在所有应用程序窗口上设置SyncScrollingSideBySide属性,而不仅仅是两个比较文档中的一个
- 再切换属性一次