काम नहीं करता है मैंने 3 अलग-अलग कोड नमूने की कोशिश की है और वे सभी विफल हो गए हैं।एक्सेल 2010 सेल संदर्भ मेनू में मेनू आइटम कैसे जोड़ें - पुराना कोड
यहाँ एक MSFT कर्मचारी (How to show a context menu on a range) से कोड है, अन्य दो नमूने काफी ठीक उसी कोड है:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
CommandBar cellbar = this.Application.CommandBars["Cell"];
CommandBarButton button = (CommandBarButton) cellbar.FindControl(MsoControlType.msoControlButton, 0, "MYRIGHTCLICKMENU", Missing.Value, Missing.Value);
if (button == null)
{
// add the button
button = (CommandBarButton) cellbar.Controls.Add(MsoControlType.msoControlButton, Missing.Value, Missing.Value, cellbar.Controls.Count, true);
button.Caption = "Refresh";
button.BeginGroup = true;
button.Tag = "MYRIGHTCLICKMENU";
button.Click += new _CommandBarButtonEvents_ClickEventHandler(MyButton_Click);
}
}
private void MyButton_Click(CommandBarButton cmdBarbutton, ref bool cancel)
{
System.Windows.Forms.MessageBox.Show("MyButton was Clicked", "MyCOMAddin");
}
मैं जब सही पर क्लिक ताज़ा नामक एक मेनू आइटम देखने की उम्मीद कर रहा हूँ एक कोशिका। फिर भी उपर्युक्त कोड (एक्सेल 2010 में) चलाना कोई 'ताज़ा करें' मेनू आइटम नहीं है।
वास्तव में किसी भी सुझाव की सराहना करेंगे कि मैं क्या खो सकता हूं या यदि यह कार्यक्षमता 2007 से 2010 तक बदल गई है?
धन्यवाद, एक और ऐड-इन लोड हो रहा था और यह रीसेट कोड था जो मेरे मेनू आइटम को हटा रहा था –