none
How to add xml and images for a custom tab? RRS feed

  • Question

  • Hi, friends

    I have a custom tab for Excel2010 in C#.

    First, i write the xml markup file as follow:

    ......

    <button id="button1" getImage="LoadImageOne" ....../>

    <button id="button2" getImage="LoadImageTwo" ....../>

    ......

    And then i write their callbacks as follow:

    public Bitmap LoadImageOne(Office.IRibbonControl control)
            {
                Bitmap midPic;
                midPic = null;
                midPic = new Bitmap(Properties.Resources.image1);
                return midPic;
            }
            public Bitmap LoadImageTwo(Office.IRibbonControl control)
            {
                Bitmap midPic;
                midPic = null;
                midPic = new Bitmap(Properties.Resources.image2);
                return midPic;
            }

    ......

    If the number of controls is large, i will write many callbacks.

    So i want to merger these callbacks, but i don't know.

    Please help me,thanks!





    • Edited by hopedream Sunday, May 4, 2014 11:05 AM
    Sunday, May 4, 2014 9:07 AM

Answers

  • Hello,

    You can specify the same callback for all controls:

    <button id="button1" getImage="LoadImage" ....../>
    
    <button id="button2" getImage="LoadImage" ....../>
    

    In the callback code you can check out the parameter passed and return a corresponding image.

    • Marked as answer by hopedream Monday, May 5, 2014 1:07 AM
    Sunday, May 4, 2014 12:42 PM
  • You can check out the IRibbonControl.Id property.

    • Marked as answer by hopedream Monday, May 5, 2014 1:07 AM
    Sunday, May 4, 2014 3:50 PM

All replies

  • Hello,

    You can specify the same callback for all controls:

    <button id="button1" getImage="LoadImage" ....../>
    
    <button id="button2" getImage="LoadImage" ....../>
    

    In the callback code you can check out the parameter passed and return a corresponding image.

    • Marked as answer by hopedream Monday, May 5, 2014 1:07 AM
    Sunday, May 4, 2014 12:42 PM
  • Hello,

    You can specify the same callback for all controls:

    <button id="button1" getImage="LoadImage" ....../>
    
    <button id="button2" getImage="LoadImage" ....../>

    In the callback code you can check out the parameter passed and return a corresponding image.

    If you can, please give an example to check out the parameters passed.

    • Edited by hopedream Sunday, May 4, 2014 3:20 PM
    Sunday, May 4, 2014 3:20 PM
  • You can check out the IRibbonControl.Id property.

    • Marked as answer by hopedream Monday, May 5, 2014 1:07 AM
    Sunday, May 4, 2014 3:50 PM
  • Eugene Astafiev,

    thanks for your reply. I have solved my question with your help.


    • Edited by hopedream Monday, May 5, 2014 1:11 AM
    Monday, May 5, 2014 1:11 AM