启用 - 在为ms字线穿过vsto时禁用按钮

时间:2014-11-14 07:30:57

标签: vsto office-addins

我对线程非常陌生并且不清楚为什么在我的代码中发生这种情况,当我点击验证文档中超链接的按钮时,我启动一个新线程,一旦启动就进行验证我想禁用功能区按钮并在线程完成后再次启用它但这没有发生,我不知道是什么错误。这是我到目前为止所尝试的:

     public class Alpha :Ribbon1
     {
        // This method that will be called when the thread is started
        public void Beta() 
        {
             foreach() { //do something }  after this loop ,enable the button again 
             button.enable=true  //not applying 
        }             }                                                                                    

        private void button_Click(object sender, RibbonControlEventArgs e)
        {
                Alpha oAlpha = new Alpha();
                     // Create the thread object, passing in the Alpha.Beta method
               Thread oThread = new Thread(new ThreadStart(oAlpha.Beta));
                    // MessageBox.Show("Please wait till the document is checked for invalid links");
                   // Start the thread
                 oThread.Start();
             button7.Label = "Pls wait";
             button7.Enabled = false;
           }

1 个答案:

答案 0 :(得分:0)

在启用/禁用以使更改生效后,需要再次呈现功能区,您可以通过调用IRibbonUI.Invalidate()

来执行此操作。