OliverM
Guest
|
I want to add context menu check boxes to the sheet tab. As the value is specific for every sheet I need to intercept the sheet tab right click event in order to check/uncheck the control before the menu shows.
Is this possible? |
|
Andrei Smolin
Add-in Express team
Posts: 18816
Joined: 2006-05-11
|
Hello Oliver,
Is this what you are looking for?
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.adxRibbonContextMenu1 = new AddinExpress.MSO.ADXRibbonContextMenu(this.components);
this.adxRibbonButton1 = new AddinExpress.MSO.ADXRibbonButton(this.components);
//
// adxRibbonContextMenu1
//
this.adxRibbonContextMenu1.ContextMenuNames.AddRange(new string[] {
"Excel.ContextMenuWorkbookPly"});
this.adxRibbonContextMenu1.Controls.Add(this.adxRibbonButton1);
this.adxRibbonContextMenu1.Ribbons = AddinExpress.MSO.ADXRibbons.msrExcelWorkbook;
//
// adxRibbonButton1
//
this.adxRibbonButton1.Caption = "adxRibbonButton1";
this.adxRibbonButton1.Id = "adxRibbonButton_13e5eefcffc64765adf8fea4ab4a2e5f";
this.adxRibbonButton1.ImageTransparentColor = System.Drawing.Color.Transparent;
this.adxRibbonButton1.Ribbons = AddinExpress.MSO.ADXRibbons.msrExcelWorkbook;
this.adxRibbonButton1.PropertyChanging += new AddinExpress.MSO.ADXRibbonPropertyChanging_EventHandler(this.adxRibbonButton1_PropertyChanging);
//
// AddinModule
//
this.AddinName = "MyAddin74";
this.SupportedApps = AddinExpress.MSO.ADXOfficeHostApp.ohaExcel;
}
...
private void adxRibbonButton1_PropertyChanging(object sender, ADXRibbonPropertyChangingEventArgs e) {
if (e.PropertyType == ADXRibbonControlPropertyType.Caption) {
object context = e.Context;
Excel.Window window = context as Excel.Window;
if (window != null) {
object sheet = window.ActiveSheet;
Excel._Worksheet wks = sheet as Excel._Worksheet;
string sheetName = (wks == null) ? "none" : wks.Name ;
e.Value = "My Button: " + window.Caption + " : " + sheetName;
} else {
e.Value = "null";
}
}
}
Andrei Smolin
Add-in Express Team Leader |
|
OliverM
Guest
|
Hi Andrei,
This is exactely what I was looking for! Appreciate the quick response! |
|
Andrei Smolin
Add-in Express team
Posts: 18816
Joined: 2006-05-11
|
You are welcome!
Andrei Smolin
Add-in Express Team Leader |
|