简体   繁体   English

如何将上下文菜单项添加到Visual Studio的C#编辑器?

[英]How can I add Context Menu Items to C# Editor of Visual Studio?

I found some example where we can add context menu items to C# code editor at compile time but not at runtime. 我找到了一些示例,可以在编译时但不在运行时将上下文菜单项添加到C#代码编辑器中。 How can we do this at run-time. 我们如何在运行时执行此操作。

Buttons belonging to commands are always added to commandbars (menus, toolbars, context menus) when the extension is registered within Visual Studio (a one-time event). 在Visual Studio中注册扩展时(一次事件),属于命令的按钮总是添加到命令栏(菜单,工具栏,上下文菜单)中。

What can be customized is whether the command is enabled/disabled and whether buttons created from it are visible/invisible. 可以自定义的是该命令是否已启用/禁用以及由此命令创建的按钮是否可见/不可见。 This can be customized: 可以自定义:

1) When the extension is not loaded yet, it is done in the .vsct file through command flags such as DefaultDisabled, DefaultInvisible, etc or VisibilityConstraints . 1)扩展名尚未加载时,可通过命令标志(例如DefaultDisabled,DefaultInvisible等VisibilityConstraints)在.vsct文件中完成。

2) When the extension is loaded, it is done using the DynamicVisibility command flag in .vsct file and OleMenuCommand.BeforeQueryStatus Event . 2)加载扩展名时,使用.vsct文件中的DynamicVisibility命令标志和OleMenuCommand.BeforeQueryStatus Event来完成 See for example: Dynamic Menu Commands in Visual Studio Packages – Part 2 例如,请参阅: Visual Studio软件包中的动态菜单命令–第2部分

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用C#将具有子项的项添加到系统上下文菜单 - How to add items with subitems to system context menu using C# 如何在Visual Studio 2010中将自己的扩展名添加到html / aspx代码编辑器的上下文菜单中? - How to add your own extension in Visual Studio 2010 to the context menu of the html/aspx code editor? 如何在Visual Studio 2010中将新项添加到项目上下文菜单? - How to add new items to the Add New Item to project context menu in visual studio 2010? 如何将根据c#的附加行为创建的上下文菜单添加到DataGrid? - How can I add to a DataGrid a context menu created from a attached behavior on c#? C#:如何在运行时添加下拉菜单项 - c#: How do i add dropdown menu items at runtime 我如何在DataGridView中的C#中创建上下文菜单 - How can i create a context menu in c# in a datagridview 如何添加嵌套上下文菜单-Visual Studio插件 - How to add nested context menu - visual studio addin Visual Studio AddIn:如何将项目特定命令添加到解决方案资源管理器上下文菜单 - Visual Studio AddIn: How do I Add Item Specific Commands to the Solution Explorer Context Menu 如何在我的 C# Visual Studio 项目中添加 VC++ DLL 作为参考? - How can I add a VC++ DLL as a reference in my C# Visual Studio project? 如何在一个连接中添加多个查询(Visual Studio C# 到 PostgreSQL) - How Can I add more then one query in one connection (Visual Studio C# to PostgreSQL)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM