Frank Jepsen
Posts: 14
Joined: 2016-07-05
|
I got a RibbonDropDown in my ExcelAddin. I react on changes with
procedure TZDataXAddInModule.tabToolsControls0Controls1Change(Sender: TObject;
const RibbonControl: IRibbonControl);
begin
case tabTools.Controls[0].AsRibbonGroup.Controls[1].AsRibbonDropDown.SelectedItemIndex of
0: ZDataModule.ConnectDB(ZDataModule.ADOConnection, 'Z1', False);
1: ZDataModule.ConnectDB(ZDataModule.ADOConnection, 'Z2', False);
2: ZDataModule.ConnectDB(ZDataModule.ADOConnection, 'Z1', True);
3: ZDataModule.ConnectDB(ZDataModule.ADOConnection, 'Z2', True);
end;
end;
When the addin gets loaded I want to initialize SelectedItemIndex with a value I read from registry. What is best way to do this.
Greetings Frank |
|
Andrei Smolin
Add-in Express team
Posts: 18825
Joined: 2006-05-11
|
Hello Frank,
Specify the SelectedItemIndex property at design time.
Andrei Smolin
Add-in Express Team Leader |
|
Frank Jepsen
Posts: 14
Joined: 2016-07-05
|
Since I read the value from registry designtime is no option.
I now read the registry in OnCreate of my DataModule and set the SelectedItemIndex in the OnRibbonLoaded event:
procedure TZDataXAddInModule.adxCOMAddInModuleRibbonLoaded(Sender: TObject;
const RibbonUI: IRibbonUI);
var
Sel: Integer;
begin
Sel := 0;
if ZDataModule.DB = 'Z2' then
Sel := 1;
if ZDataModule.Local then
Inc(Sel, 2);
tabTools.Controls[0].AsRibbonGroup.Controls[1].AsRibbonDropDown.SelectedItemIndex := Sel;
end;
But I am not sure if it is the best time to do it.
It seems to work though.
Frank |
|
Andrei Smolin
Add-in Express team
Posts: 18825
Joined: 2006-05-11
|
Hello Frank,
The moment is okay. I would probably prefer to do this in the OnRibbonBeforeCreate event. But OnRibbonLoaded is okay as well.
Andrei Smolin
Add-in Express Team Leader |
|