【发布时间】:2011-08-17 01:45:58
【问题描述】:
我正在实现书中的代码以在 Excel 中创建自定义操作窗格
using System;
使用 System.Data; 使用 System.Drawing; 使用 System.Windows.Forms; 使用 Microsoft.VisualStudio.OfficeTools.Interop.Runtime; 使用 Excel = Microsoft.Office.Interop.Excel; 使用 Office = Microsoft.Office.Core;
命名空间 ExcelWorkbook1 { 公共部分类Sheet1 { 公共按钮 customerButton = new Button(); public Button inventoryButton = new Button();
private void Sheet1_Startup(object sender, EventArgs e)
{
customerButton.Text = "Select a customer...";
inventoryButton.Text = "Check inventory...";
this.orderInfo.Selected +=
new Excel.DocEvents_SelectionChangeEventHandler(
OrderInfo_Selected);
this.orderInfo.Deselected +=
new Excel.DocEvents_SelectionChangeEventHandler(
OrderInfo_Deselected);
this.customerInfo.Selected +=
new Excel.DocEvents_SelectionChangeEventHandler(
CustomerInfo_Selected);
this.customerInfo.Deselected +=
new Excel.DocEvents_SelectionChangeEventHandler(
CustomerInfo_Deselected);
}
#region VSTO Designer generated code
private void InternalStartup()
{
this.Startup += new System.EventHandler(Sheet1_Startup);
}
#endregion
void OrderInfo_Selected(Excel.Range target)
{
Globals.ThisWorkbook.ActionsPane.Controls.Add(inventoryButton);
}
void OrderInfo_Deselected(Excel.Range target)
{
Globals.ThisWorkbook.ActionsPane.Controls.Remove(inventoryButton);
}
void CustomerInfo_Selected(Excel.Range target)
{
Globals.ThisWorkbook.ActionsPane.Controls.Add(customerButton);
}
void CustomerInfo_Deselected(Excel.Range target)
{
Globals.ThisWorkbook.ActionsPane.Controls.Remove(customerButton);
}
} }
然而
代码this.order.Selected' is not regconized
你对我有什么建议吗?
谢谢
【问题讨论】:
-
您缺少一些代码,orderInfo 和 customerInfo 是什么?
标签: c# excel office-2007