EXCEL里面插入一个子窗体
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml.Linq;
using Microsoft.Office.Tools.Excel;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
namespace ExcelWorkbook1
{
public partial class Sheet1
{
private void Sheet1_Startup(object sender, System.EventArgs e)
{
}
private void Sheet1_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO 设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InternalStartup()
{
this.button1.Click += new System.EventHandler(this.button1_Click);
this.Startup += new System.EventHandler(this.Sheet1_Startup);
this.Shutdown += new System.EventHandler(this.Sheet1_Shutdown);
}
#endregion
Form fm = new Form1();
private void button1_Click(object sender, EventArgs e)
{
fm.Show();
fm.ParentForm =ThisWorkbook
}
}
}
这段代码,红色部分怎么写才对。
意思是在EXCEL上画一个按钮,点击这个按钮,然后打开窗体1.
并且让这个窗体为EXCEL的子窗体。