首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VBA >

VSTO编程,Excel2007的Worksheet_SelectionChange事件失效有关问题

2012-03-14 
VSTO编程,Excel2007的Worksheet_SelectionChange事件失效问题具体测试:在Excel2007中按住向下(或向右键)移

VSTO编程,Excel2007的Worksheet_SelectionChange事件失效问题
具体测试:在Excel2007中按住向下(或向右键)移动一段时间后,Worksheet_SelectionChange事件就失效了,请高手帮我看看,代码如下:

C# code
    public partial class ThisAddIn    {        private void ThisAddIn_Startup(object sender, System.EventArgs e)        {            this.Application.Worksheets[1].SelectionChange +=                new Excel.DocEvents_SelectionChangeEventHandler(Worksheet_SelectionChange);            this.Application.SheetActivate +=                 new Excel.AppEvents_SheetActivateEventHandler(Application_SheetActivate);        }        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)        {        }        private void Worksheet_SelectionChange(Excel.Range target)        {            this.Application.StatusBar = "选中的单元格内容为:" + string.Format("Address:{0}, Value:{1}, Value2:{2}", target.Address, target.Value, target.Value2);        }        private void Application_SheetActivate(object obj)        {            this.Application.ActiveSheet.SelectionChange +=                new Excel.DocEvents_SelectionChangeEventHandler(Worksheet_SelectionChange);        }                #region VSTO generated code        /// <summary>        /// Required method for Designer support - do not modify        /// the contents of this method with the code editor.        /// </summary>        private void InternalStartup()        {            this.Startup += new System.EventHandler(ThisAddIn_Startup);            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);        }        #endregion    }


[解决办法]
高见,顶

热点排行