问题
TopMost
it's not good because it's on top of all the applications in the computer.
Except ShowDialog() way, because it's lock the Application.
回答1:
You need to use a modaless dialog in order not to block the Main Office application. You also need to set the Office Application as parent window of the modaless dialog.
1) Use the WindowWrapper class from this answer.
2) Lets assume you have the access to Application object of your Office app. App.WindowHandle32 is the handle to the main Window.
3) Code:
var someDialog = new Form1();
someDialog.Show(new WindowWrapper(new IntPtr(App.WindowHandle32)));
4) Remember to declare the someDialog
variable as a class member.
来源:https://stackoverflow.com/questions/61756628/in-office-add-in-c-there-is-an-option-to-open-form-on-top-of-the-office-applic