1
Context:
With the use of a personal app made on Delphi-7, I have been adding new actions as needed in a TRadioGroup
, but now contains many items (16), harming the usability of the application.
What I wanted to do was categorize these items from TRadioGroup
in a TComboBox
, so it would have some categories and the TRadioGroup
would take
fewer options, thus improving the visual layout and facilitating choice.
Need:
Create a TComboBox
dynamically based on a file .ini
, as if
if it were a configuration for loading the `Tcombobox, it would look something like this:
[CATEGORIA]
0=CATEGORIA1
1=CATEGORIA2
2=CATEGORIA3
With the category defined and clicking on TComboBox
then load the items from TRadioGroup
based on the group, a .ini
, sort of like this, I thought:
[CATEGORIA_1]
0=ITEM1
1=ITEM2
[CATEGORIA_2]
0=ITEM1
1=ITEM2
2=ITEM3
3=ITEM4
4=ITEM5
[CATEGORIA_3]
0=ITEM1
1=ITEM2
2=ITEM3
Currently my code using INI is only to save the last selected option, and when reopening the program already bring:
.INI
[CONFIG]
INDEXGROUP=1
Procedure SalvarINI
:
procedure SalvarINI;
var
vlIni: TIniFile;
begin
try
vlIni := TIniFile.Create(ExtractFileDir(Application.ExeName) +'\'+ ExtractFileName(Application.ExeName)+'.ini');
try
vlIni.WriteInteger('CONFIG', 'INDEXGROUP',rgItens.ItemIndex);
vlIni.UpdateFile;
finally
vlIni.Free;
end;
except
on e: exception do
begin
ShowMessage('Ops..não conseguimos Salvar as configurações: '+ e.Message);
end;
end;
end;
carregarINI
procedure carregarIni;
var
vlIni: TIniFile;
begin
vlIni := TIniFile.Create(ExtractFileDir(Application.ExeName) +'\'+ ExtractFileName(Application.ExeName)+'.ini');
try
RGProduto.ItemIndex := vlIni.ReadInteger('CONFIG' ,'INDEXGROUP',1);
finally
FreeAndNil(vlIni);
end;
end;
Thank you