大佬教程收集整理的这篇文章主要介绍了c# – Quick Analysis右键单击上下文菜单会被Quick Analysis默认值覆盖,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
当我在命名表范围外右键单击时,我从示例中修改的代码版本就像一个魅力:
但是当您在命名表范围内右键单击时,它不会显示:
我想它与快速分析功能有关,干扰了我的自定义上下文菜单覆盖.这是我在ThisAddin.cs中使用的代码:
void Application_SheetBeforeRightClick(object worksheet,Excel.Range range,ref bool cancel) { GetCellContextMenu().Reset(); // reset the cell context menu BACk to the default // If the SELEcted range belongs within a named excel table we display the refresh menu item at the right click context menu. if (true) //range.IntersectsWithAnyExcelTable()) <-- this code works fine but I commented it out for the purpose of showing the problem (in this case the custom popup meny should appear ALWAYS): { const OfficeCore.MsoControlType menuItem = OfficeCore.MsoControlType.msoControlButton; var refreshMenuItem = (OfficeCore.CommandBarButton)GetCellContextMenu().Controls.Add(menuItem,missing,1,truE);// where missing = global::System.Type.Missing; refreshMenuItem.Style = OfficeCore.MsoButtonStyle.msoButtonCaption; refreshMenuItem.Caption = "refresh My Data"; refreshMenuItem.Click -= refreshMenuItemClick; refreshMenuItem.Click += refreshMenuItemClick; } }
并且不要忘记在加载项启动时订阅事件:
Application.SheetBeforeRightClick += Application_SheetBeforeRightClick;
我怎么能:
以上是大佬教程为你收集整理的c# – Quick Analysis右键单击上下文菜单会被Quick Analysis默认值覆盖全部内容,希望文章能够帮你解决c# – Quick Analysis右键单击上下文菜单会被Quick Analysis默认值覆盖所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。