插入节点后定位光标 [英] Position cursor after inserted nodes

查看:60
本文介绍了插入节点后定位光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个将WordML文档片段导入文档的解决方案。对于我插入的每个文档,我想将光标定位在插入的节点之后。

我想我可以用某种方式使用Selection对象和Move方法,但我不知道如何。

我还希望将光标放在元素结尾之前。我该怎么做?

注意!

// Johan

I have a solution that import WordML document fragments into a document. For each document I insert, I would like to position the cursor after the inserted node.

I suppose I can use the Selection object and the Move methods in some way, but I don't know how.

I would also like to place the cursor just before the end of an element. How do I do this?

Regard!

// Johan

推荐答案

设置光标位置几乎总是涉及使用范围。应用程序对象的选择属性,文档对象内容属性以及各种其他构造(如"句子")都基本上只是范围。

Setting the cursor position will almost always involve using a range. The application object's selection property, a document object contents property, and various other constructs such as 'sentences' are all basically just ranges.

您可以使用wordApp.Selection.MoveUntil(指定文本)如果你想找到具体的东西。然后wordApp.Selection.Collapse(WdCollapseEnd)会将选择减少到只有光标。

You can use wordApp.Selection.MoveUntil(specified text) if you want to find something specific. Then wordApp.Selection.Collapse(WdCollapseEnd) would reduce the selection to just the cursor.

 

 

根据MSDN,XML节点接口具有范围属性。所以我认为你可以使用:

According to MSDN, the XML node interface has a range property. So I think you could use:

 

int position = xmlNode.Range.End;

int position = xmlNode.Range.End;

wordApp.Selection.SetRange(位置,位置);

wordApp.Selection.SetRange(position, position);

 

 


这篇关于插入节点后定位光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆