create a new project. I insert one ComboBox into the project and 1 editbox into the project. then I menambhkan string item in combobox list of items
server 1 au
server 2 uk
server 3 my
after making a string in the combobox then formed a list in combobox. all I want is to add a config in the string. like if i choose server 1 au in the editbox combobox displays the server address as ns.au.server.com
ns.au.server.com server address -> string to server 1 au
combobox1-> select string item-> Server 1 au
editbox1 then displays the address ns.au.server.com
The functionality you ask for is available using TStrings Name-Value pairs.
type
TFormMain = class(TForm)
ComboBox1: TComboBox;
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
private
public
FServerConfig : TStrings;
end;
var
FormMain: TFormMain;
implementation
{$R *.dfm}
procedure TFormMain.FormCreate(Sender: TObject);
var i : integer;
begin
FServerConfig := TStringList.Create;
//Add Name = Value pairs
FServerConfig.Append('Server 1 AU=ns.au.server.com');
FServerConfig.Append('Server 2 UK=ns.uk.server.com');
FServerConfig.Append('Server 3 MY=ns.my.server.com');
for i := 0 to FServerConfig.Count - 1 do
ComboBox1.Items.Append(FServerConfig. Names[i]);
end;
procedure TFormMain.ComboBox1Change(Sender: TObject);
begin
Edit1.Text := FServerConfig.Values[ComboBox1.Text];
end;