gpt4 book ai didi

c# - 设置选择容器示例

转载 作者:太空宇宙 更新时间:2023-11-03 14:08:46 26 4
gpt4 key购买 nike

我正在寻找一个使用 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);

最佳答案

Sets the objects that should be passed to the Properties windowwhenever the window has focus. SetSelectionContainer works only onwindows created with the CreateToolWindow method. Other tool windows,such as Solution Explorer and Task List, already have code for settingwhat is displayed in the Properties window.

SetSelectionContainerallows you to associate objects with the window so that whenever thewindow has focus, the Properties window displays properties for thoseobjects. For example, you would use this property if you have a customtool window that displays a chart and you want to display propertiesin the Properties window in order to change characteristics of thechart.

If SetSelectionContainer is passed an empty Variant value, itremoves the displayed object. The object displays when the tool windowis active and the objects are available from the selection container.

Ref .

您是否从此处下载了示例?:Automation and Extensibility for Visual Studio

关于c# - 设置选择容器示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8499333/

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