Word插件中的弹出对话框 [英] popup dialog box in word addin
问题描述
我正在使用c#创建一个ms office单词插件.我有几个按钮的功能区.在单击按钮之一时,我需要一个带有几个文本框的弹出窗口. 问:如何在单词插件中创建弹出对话框?
I am creating a ms office word addin using c#. I have a ribbon with several button. On clicking one of the button I need a popup with few textboxes. Question: How to create a popup dialog in word addin?
推荐答案
将新的Form添加到您的外接程序项目中,并根据需要进行设计.
Add a new Form to your add-in project and design as desired.
在按钮单击处理程序中,您只需执行"new MyPopupDialog().Show();".如果要使Word窗口成为对话框的父级,以便可以将其居中并使其对单词窗口具有模式,则可以创建一个可以在"new MyPopupDialog().ShowDialog(WordWindowWarper);"中使用的窗口包装器类. .像这样:
In your button click handler you just need to do "new MyPopupDialog().Show();". If you want to make the Word window the parent of your dialog so you can centre it and make it modal to the word window you can make a window wrapper class that you can use in "new MyPopupDialog().ShowDialog(WordWindowWarper);". Something like this:
public class WindowWrapper : IWin32Window
{
public WindowWrapper(IntPtr handle)
{
Handle = handle;
}
public IntPtr Handle { get; private set; }
}
句柄是Word应用程序窗口的窗口句柄.
The handle being the window handle of the Word application window.
这篇关于Word插件中的弹出对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!