设置选择容器示例
我正在寻找一个使用 c# 调用 EnvDTE.Window 类上的 SetSelectionContainer 方法的简单示例。
我想知道我应该传递给该方法的类应该是什么样子。
我已经在网上搜索了好几天了,甚至找不到任何有帮助的东西。
Window window = _applicationObject.ItemOperations.NewFile(@"General\XML File", "", "");
TextSelection selection = (TextSelection) window.Document.Selection;
selection.SelectAll();
selection.Insert("<xml>some xml<xml>", (int)vsInsertFlags.vsInsertFlagsContainNewText);
object[] container = new[] {"Test1", "Test2"};
window.SetSelectionContainer(ref container);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
参考。
您是否从此处下载了示例?: 自动化和 Visual Studio 的可扩展性
Ref.
Have you downloaded the samples from here?: Automation and Extensibility for Visual Studio
根据我的发现,您可以传递简单的属性,例如此方法的对象数组参数中的字符串和整数。
看来实现这项工作的真正技巧是生成通知(通过 ITrackSelection.OnSelectChange) 属性已更改。
这里有一些工作代码。
From what I have discovered, you can pass simple properties, such as strings and ints in the object array parameters for this method.
It appears that the real trick to making this work is generating the notification (through ITrackSelection.OnSelectChange) that the properties have changed.
There is some working code for this here.