如何获得一个mshtml.IHTMLSelectionObject的开始和结束位置

本文关键字:IHTMLSelectionObject 开始 位置 结束 mshtml 一个 何获得 | 更新日期: 2023-09-27 18:18:12

下面是我的代码:

var doc = webBrowser.Document as mshtml.HTMLDocument;
            if (doc != null)
            {
                var currentSelection = doc.selection;
                if (currentSelection != null)
                {
                    var selectionRange = currentSelection.createRange();

我可以得到selectionRange的起始和结束位置吗?

如何获得一个mshtml.IHTMLSelectionObject的开始和结束位置

public IHTMLTxtRange CurrentSelection
{
    get
    {
        var htmlDocument = webBrowser.Document.DomDocument as IHTMLDocument2;
        IHTMLSelectionObject currentSelection = htmlDocument.selection;
        IHTMLTxtRange range = null;
        if (currentSelection != null)
        {
            range = currentSelection.createRange() as IHTMLTxtRange;
            //range.moveStart("wdCell",1);
            //range.moveEnd("wdCell",1);
        }
        return range;
    }
}

范围。MoveStart方法
以编程方式在文档中扩展范围
WdUnits枚举

相关文章:
  • 没有找到相关文章