为什么在切换到Excel Interop后,我的表单会丢失其“模态”对话框?

时间:2019-02-15 12:07:34

标签: c# .net vsto excel-interop

我正在尝试使用以下代码在VSTO应用程序中完成RedEdit控制

            System.Drawing.Size windowSize = form.Size;
            form.Size = SystemInformation.MinimumWindowSize;
            System.Drawing.Point location = form.Location;
            SetFormPositionForInputBox(form);

            string rangeAddress = string.Empty;
            Excel.Range range = null;
            try
            {
                range = Globals.ThisAddIn.Application.InputBox(prompt, title, Type.Missing, Type.Missing,
                                        Type.Missing, Type.Missing, Type.Missing, 8) as Excel.Range;

                if (range != null)
                    rangeAddress = range.get_AddressLocal(Office.MsoTriState.msoFalse,
                                                          Office.MsoTriState.msoFalse,
                                                          Excel.XlReferenceStyle.xlA1,
                                                          Office.MsoTriState.msoFalse,
                                                          Type.Missing);

            }
            catch
            {
                form.Close();
                throw new Exception("An error occured when selecting the range.");
            }
            finally
            {
                form.Location = location;
                form.Size = windowSize;
                //  MRCO(range);
            }
            return rangeAddress;

一切正常,它显示输入框并获取地址,但是获取地址后,它不再是模式形式(ShowDialog)。有什么建议可以避免这种情况,还是有人可以在VSTO中实现更好的RefEdit?

0 个答案:

没有答案