TFormStyler from INI settings

AdvFormStyler version 2.2.1.1, AdvComboBox version 1.6.2.1


When I close my window, I save the user's preferred color scheme into an INI file.

    Ini.WriteInteger('Form','Style',integer(advformstyler1.Style));

When I load the program, in the OnShow event, I set the value from the INI file.

    i := Ini.ReadInteger('Form','Style',0);
    AdvFormStyler1.Style := TTMSStyle(i);
    AdvComboBox1.ItemIndex := i;

In the OnCreate event, I have loaded the combobox values.

procedure TForm1.FormCreate(Sender: TObject);
begin
  AdvFormStyler1.ComboBox := AdvComboBox1;
  AdvComboBox1.Clear;
  AdvComboBox1.Items.AddStrings(AdvFormStyler1.GetStyles);
end;

The program retains the correct color setting, but displays a different choice in the combobox.

Example:
  Selected Windows 7, displays Windows 10 on reload, but color is Windows 7.  Windows 10 is 2 items after Windows 7 in the drop down box.  The Style index saved is 11.

If I select Windows Office 2003 Blue (index of 0) it displays correctly.

What am I missing to set the combobox item selected correctly?

To restore the combobox state with the correct selected item, please use:


  i := Ini.ReadInteger('Form','Style',0);
    AdvFormStyler1.Style := TTMSStyle(i);
AdvFormStyler.ComboBox := AdvComboBox1;

The assignment of the AdvComboBox to AdvFormStyler.ComboBox should both load the combobox with the correct items and sync the item index to the selected style.

Thanks!  Works perfectly.