C# 将checkedlistbox添加到Excel功能区
我已经创建了一个Excel功能区。它包含一个下拉列表,在该下拉列表中,打开工作簿时将填充工作簿中所有工作表的名称。现在,我想从下拉列表中选择多张图纸,并仅对这些图纸执行一些操作。有没有办法从下拉列表中选择多项选择。Checkedlistbox控件不适用于Excel功能区。这是我所知道的处理这种情况的唯一方法。任何帮助都会很好。提前谢谢。这是我的密码:C# 将checkedlistbox添加到Excel功能区,c#,excel,add-in,excel-addins,C#,Excel,Add In,Excel Addins,我已经创建了一个Excel功能区。它包含一个下拉列表,在该下拉列表中,打开工作簿时将填充工作簿中所有工作表的名称。现在,我想从下拉列表中选择多张图纸,并仅对这些图纸执行一些操作。有没有办法从下拉列表中选择多项选择。Checkedlistbox控件不适用于Excel功能区。这是我所知道的处理这种情况的唯一方法。任何帮助都会很好。提前谢谢。这是我的密码: namespace Ribbon { public partial class ExcelRibbon { List<
namespace Ribbon {
public partial class ExcelRibbon {
List<string> Sheets = new List<string>();
private void ExcelRibbon_Load(object sender, RibbonUIEventArgs e) {
Globals.ThisAddIn.Application.WorkbookOpen += new Excel.AppEvents_WorkbookOpenEventHandler(Application_WorkbookOpen);
}
void Application_WorkbookOpen(Excel.Workbook Wb) {
SheetsCollection.Items.Clear();
for (int i = 1; i < Globals.ThisAddIn.Application.Sheets.Count; i++) {
RibbonDropDownItem item = this.Factory.CreateRibbonDropDownItem();
item.Label = Globals.ThisAddIn.Application.Sheets[i].Name;
SheetsCollection.Items.Add(item);
}
}
private void SheetsCollection_SelectionChanged(object sender, RibbonControlEventArgs e) {
SheetsCollection.SelectedItem.Label = SheetsCollection.SelectedItem.Label + " *";
if(SheetsCollection.SelectedItem.Label.EndsWith("*"))
Sheets.Add(SheetsCollection.SelectedItem.Label.Substring(0,SheetsCollection.SelectedItem.Label.LastIndexOf(" ");
}
}
}
命名空间功能区{
公共部分类{
列表页=新列表();
私有void ExcelRibbon\u加载(对象发送器,RibbonUIEventArgs e){
Globals.ThisAddIn.Application.WorkbookOpen+=新的Excel.AppEvents\u WorkbookOpenEventHandler(Application\u WorkbookOpen);
}
作废应用程序\u工作簿打开(Excel.Workbook Wb){
SheetsCollection.Items.Clear();
对于(int i=1;i