ComboBox autowybiernaie

0

Na pewno to jest banalne ale nie umię tego znaleźć czyli jak ustawić tekst który jest jednym z itemów w combox przez inny komponent. Spróbuję jaśniej, gdy wybieram na jednym comboxie wartość to na drugim comboxie ustawia sie przyporządkowana wartośc dla pierwszego comboxa (to nieistotne ale dane w comboxach pochodzą z bazy danych).
[glowa]

0

w sumie dokładnie sam nie wiem o co tobie chodzi, ale jeżeli patent ma być taki, że:

  1. 2xcombobox
  2. każdy combobox ma tyle samo itemów
  3. wybierając item z combobox2 jest pobierany index wyboru
  4. index wyboru CB2 jest ustawiany w combobox1
procedure TForm1.ComboBox2Select(Sender: TObject);
begin
case combobox2.ItemIndex  of
0:combobox1.Text:=combobox1.Items[0];
1:combobox1.Text:=combobox1.Items[1];
2:combobox1.Text:=combobox1.Items[2];
3:combobox1.Text:=combobox1.Items[3];
4:combobox1.Text:=combobox1.Items[4];
5:combobox1.Text:=combobox1.Items[5];
6:combobox1.Text:=combobox1.Items[6];
7:combobox1.Text:=combobox1.Items[7];
8:combobox1.Text:=combobox1.Items[8];
9:combobox1.Text:=combobox1.Items[9];
10:combobox1.Text:=combobox1.Items[10];
11:combobox1.Text:=combobox1.Items[11];
12:combobox1.Text:=combobox1.Items[12];
13:combobox1.Text:=combobox1.Items[13];
14:combobox1.Text:=combobox1.Items[14];
15:combobox1.Text:=combobox1.Items[15];
end;
end;
//podczas pojawiania sie formatki sa uzupelniane CBki
procedure TForm1.FormCreate(Sender: TObject);
var
i:integer;
begin
for i:= 0 to 15 do
begin
combobox1.Items.Add('item '+inttostr(i));
combobox2.Items.Add('przedmiot '+inttostr(i));
end;
combobox1.Text:=combobox1.Items[0];
combobox2.Text:=combobox2.Items[1];
end;
0

CB1.ItemIndex := CB2.ItemIndex;

0

no, w sumie na skróty tez można =]

0

Trochę namieszałem. Chodziło mi oto by poazał mi comboź wartośc którą posiada w itemach na podstawie stringa który inicjowany był z innego comboxa. Pewno namieszłem jeszcze bardziej, ale spox udało ms się to znaleźć:

ComboBox.ItemIndex := ComboBox.Items.IndexOf(String);

Dzięki za pomoc :-)

1 użytkowników online, w tym zalogowanych: 0, gości: 1