Refresh Dropdowns

Add-in Express™ Support Service
That's what is more important than anything else

Refresh Dropdowns
 
Daniel Triendl


Guest


Hello,

I want my addin to automatically fill some dropdown boxes and change the selected element, etc, but sometimes the contend and/or the selected elements are not refreshed correctly. Is there a special procedure to follow to force office application to refresh the commandbars?

My code looks something like this:

  procedure FillComboBox(Box: TadxCommandBarDropDownList);
  var
    i: integer;
  begin
    Box.Clear;
    
    Box.Text := '';
    Box.Items.Text := FCompanies.Text;
    

    if FCompanies.Find(FSettings.Company, i) then
    begin
      TadxCommandBarDropDownList(Box).ListIndex := i + 1
      Box.Text := FCompanies.Strings[i];
    end else
    begin
      TadxCommandBarDropDownList(Box).ListIndex := 1;
    end;
  end;
Posted 06 Dec, 2010 02:06:50 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Daniel,

What host application is your add-in developed for? What event handlers do you use to fill in your drop down boxes? How can I reproduce the issue you described? Could you please send me your project (or some demo project with the same behavior) for testing?
Posted 06 Dec, 2010 09:09:29 Top
Daniel Triendl


Guest


The host application is Word. I have seen this problem in Word 2003 but not in Word 2007.

During the OnAddInInitialize event some default values are generated and the dropdown is filled with this values, but sometimes the old values stay there, but not always. I'll try to make a demo and recheck my code to see if the problem is there.
Posted 06 Dec, 2010 09:57:47 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Daniel,

Thank you for the details. Also please try to use the OnAddInStartupComplete event instead of OnAddInInitialize. The OnAddInStartupComplete event is raised when all command bar controls are added and connected.
Posted 06 Dec, 2010 10:14:55 Top
Daniel Triendl


Guest


Thanks, I'll try that. Also, setting the temporary property on the command bar seems to help. Maybe it's a caching issue with Words Normal.dot?
Posted 06 Dec, 2010 10:20:45 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Daniel,

Yes, all non-temporary controls are saved/cached in the normal.dot template. But again, I would suggest using the OnAddInStartupComplete event.
Posted 06 Dec, 2010 11:17:40 Top