none
RibbonDropDown empty RRS feed

  • Question

  • Hi,

    I have created a new Ribbon tab for Microsoft.Outlook.Mail.Compose in Outlook 2010.

    I'm filling a RibbonDropDown at runtime with some SQL data.

    Everything is fine at the first time when I compose a new mail message, the dropdown is filled in with the data.

    The next time, when I want to compose a new mail message, the dropdown is empty. When I debug, the method is called correctly.

    private void RibbonDistributionList_Load(object sender, RibbonUIEventArgs e)
    {
    	MyManager mgr = new MyManager();
    	DistributionListList list = mgr.GetDL();
    	foreach (DistributionList dl in list)
    	{
    		RibbonDropDownItem rdi = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
    		rdi.Label = dl.Name;
    		rdi.Tag = dl.DistributionListId;
    
    		Globals.Ribbons.RibbonDistributionList.ddlDistributionLists.Items.Add(rdi);
    	}
    }

    Do you have any idea ?

    Thx for your help.

    MisterG


    • Edited by MisterG Monday, May 14, 2012 9:37 PM
    Monday, May 14, 2012 9:32 PM

Answers

  • I forget the designer because it does not work and I have created a new Ribbon XML and it's kind of working.
    • Marked as answer by MisterG Tuesday, May 22, 2012 9:27 PM
    Tuesday, May 22, 2012 9:27 PM

All replies

  • Hi MisterG,

    Please add this line to the head of foreach circle.

    this.RibbonUI.Invalidate();

    Let's see whether it works.

    Best Regards,

    T.X.

    Tuesday, May 15, 2012 7:48 AM
  • Hi T.X.,

    Thanks for your help but it does not change anyhting :-(

    I have also tried InvalidateControl(controlId), same result, the dropdown remains empty.

    Regards,

    MisterG

    Tuesday, May 15, 2012 4:03 PM
  • you should attach to NewInspector event and call ribbon.invalidatecontrol(your dropdownid). in xml or designer defining your dropdown provide callbacks for gettin list item count and list items for your dropdown.
    Tuesday, May 15, 2012 5:41 PM
  • Sorry Damian, I don't understand what you mean.

    When I look at this example : http://msdn.microsoft.com/en-us/library/bb608628, they have nothing to invalidate.

    I have tried this code and it's not working:

    public partial class ThisAddIn
    	{
    		private Outlook.Inspectors inspectors;
    		private void ThisAddIn_Startup(object sender, System.EventArgs e)
    		{
    			inspectors = this.Application.Inspectors;
    			inspectors.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
    		}
    
    		private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
    		{
    			inspectors.NewInspector -= new Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
    			inspectors = null;
    		}
    
    		private void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector inspector)
    		{
    			Outlook.MailItem mailItem = inspector.CurrentItem as Outlook.MailItem;
    
    			if (mailItem != null)
    			{
    				if (Globals.Ribbons.RibbonDistributionList != null && Globals.Ribbons.RibbonDistributionList.RibbonUI != null)
    				{
    					Globals.Ribbons.RibbonDistributionList.RibbonUI.InvalidateControl(Globals.Ribbons.RibbonDistributionList.ddlDistributionLists.Id);
    				}
    			}
    		}
    }

    Tuesday, May 15, 2012 8:40 PM
  • you want to dynamically provide different items for dropdown depending on something (mail, etc) or you want to statically add items to dropdown on outlook start and be done with it?
    Wednesday, May 16, 2012 8:51 AM
  • The items are coming from the database, always the same.

    It's only in Outlook.Mail.Compose.

    Wednesday, May 16, 2012 12:05 PM
  • so you should load them only once. Provide callbacks for getItemCount, getItemID and getItemLabel, respond to them once to fill dropdown and be done with it. Do not call invalidate nowhere or refill in response to some event and it should work.

    Wednesday, May 16, 2012 1:18 PM
  • OK, I'll try that.

    But if someone changes the values in the database how can I reload the items in the dropdown ?

    Wednesday, May 16, 2012 1:25 PM
  • then you need to call ribbon.invalidatecontrol(id of your dropdown)
    Wednesday, May 16, 2012 1:55 PM
  • so you should load them only once. Provide callbacks for getItemCount, getItemID and getItemLabel, respond to them once to fill dropdown and be done with it. Do not call invalidate nowhere or refill in response to some event and it should work.

    It does not work. I only load them once and I check if the dropdown has items before loading, same result : dropdown empty.

    this.RibbonUI.InvalidateControl(ddlDistributionLists.Id); does not work either :-(

    Wednesday, May 16, 2012 2:02 PM
  • ok, show me how you define dropdown and provide callback.
    Wednesday, May 16, 2012 2:14 PM
  • I have defined my dropdown with the Designer.

    public RibbonDistributionList() : base(Globals.Factory.GetRibbonFactory())
    		{
    			InitializeComponent();
    		}

    What do you mean by callback ? I think don't have any callback.

    Wednesday, May 16, 2012 2:33 PM
  • ok, i was talikng about ribbon xml, not a ribbon designer. Is there anywhere on designer properties window for dropdown possibility to specify callbacks for your control?
    Wednesday, May 16, 2012 7:12 PM
  • Nope. As I understand, the designer sucks and I will have to do a Ribbon XML, right ?

    Such a weird behavior...

    Thursday, May 17, 2012 9:14 AM
  • no, of course it should be also possible to create filled dropdown in designer, especially since you want static behaviour - loaded once. But i never used designer and can only help you with xml approach.

    Thursday, May 17, 2012 9:54 AM
  • So, what's the advantage to use Ribbon XML instead of the designer ? As I can see, nobody uses the designer ?
    Monday, May 21, 2012 7:53 AM
  • A lot of people use the designer.
     
    If it provides what you need it's much easier than writing ribbon XML, and overriding the service requests to handle the ribbon yourself. If you need something the ribbon designer doesn't provide, such as dynamic menus or other controls not supported in the designer you have to do it with ribbon XML and handling the callbacks you specify in the XML.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "MisterG" <=?utf-8?B?TWlzdGVyRw==?=> wrote in message news:2aab6fcb-79c5-47bf-a3df-7b064e560acd...
    So, what's the advantage to use Ribbon XML instead of the designer ? As I can see, nobody uses the designer ?

    Ken Slovak MVP - Outlook
    Monday, May 21, 2012 1:27 PM
  • I forget the designer because it does not work and I have created a new Ribbon XML and it's kind of working.
    • Marked as answer by MisterG Tuesday, May 22, 2012 9:27 PM
    Tuesday, May 22, 2012 9:27 PM