Linuxuser1234 1 Posted January 3, 2023 (edited) Im trying make a procedure that when you select an item from ComboEdit1 (it will officially list items from a ftp site) but for a test im trying to list the same item from ComboEdit1 to ComboEdit2 procedure TForm4.ComboEdit1Click(Sender: TObject); begin end; i have tried %s like ComboEdit2.Items.Add('%S'); but that doesnt work here is the list items for ComboEdit1 and i havent been able to find code examples TTUL TTPA TSTL TSLC TSJU TSDF TRDU TPIT TPHX TPHL TPBI TORD TOKC TMSY TMSP TMKE TMIA TMEM TMDW TMCO TMCI TLVE TLAS TJUA TJFK TIDS TICH TIAH TIAD THOU TFLL TEWR TDTW TDFW TDEN TDCA TDAY TDAL TCVG TCMH TCLT TBWI TBOS TBNA TATL TADW ROP4 ROP3 RODN RKSG RKJK PHWA PHMO PHKM PHKI PGUA PAPD PAKC PAIH PAHG PAEC PACG PABC NOP4 NOP3 KYUX KVWX KVTX KVNX KVBX KVAX KUEX KUDX KTYX KTWX KTLX KTLH KTFX KTBW KSRX KSOX KSJT KSHV KSGF KSFX KRTX KRLX KRIW KRGX KRAX KPUX KPOE KPDT KPBZ KPAH KOTX KOKX KOHX KOAX KNQA KNKX KMXX KMVX KMUX KMTX KMSX KMRX KMQT KMPX KMOB KMLB KMKX KMHX KMBX KMAX KMAF KLZK KLWX KLVX KLTX KLSX KLRX KLOT KLNX KLIX KLGX KLCH KLBB KJKL KJGX KJAX KIWX KIWA KINX KIND KILX KILN KICX KICT KHTX KHPX KHNX KHGX KHDX KGYX KGWX KGSP KGRR KGRK KGRB KGLD KGJX KGGW KFWS KFTG KFSX KFSD KFFC KFDX KFDR KFCX KEYX KEWX KEVX KESX KEPZ KEOX KENX KEMX KEAX KDYX KDVN KDTX KDOX KDMX KDLH KDIX KDGX KDFX KDDC KDAX KCYS KCXX KCRP KCLX KCLE KCCX KCBX KCBW KCAE KBYX KBUF KBRO KBOX KBMX KBLX KBIS KBHX KBGM KBBX KATX KARX KAPX KAMX KAMA KAKQ KABX KABR FOP1 DOP1 DAN1 Edited January 3, 2023 by Linuxuser1234 Share this post Link to post
Lars Fosdal 1792 Posted January 4, 2023 Do you want to add the selected from ComboEdit1 to the dropdown of ComboEdit2? Hook Combo1Edit.OnSelect procedure TForm4.ComboEdit1OnSelect(Sender: TObject); begin ComboEdit2.Items.Add(ComboEdit1.Text); end; This event is called when an item is selected from the dropped down list of ComboEdit1. Naturally, you need to add code to see if the item has already been added before you add it. Share this post Link to post
Linuxuser1234 1 Posted January 4, 2023 (edited) Do you want to add the selected from ComboEdit1 to the dropdown of ComboEdit2? Hook Combo1Edit.OnSelect procedure TForm4.ComboEdit1OnSelect(Sender: TObject); begin ComboEdit2.Items.Add(ComboEdit1.Text); end; This event is called when an item is selected from the dropped down list of ComboEdit1. Naturally, you need to add code to see if the item has already been added before you add it. @Lars Fosdal that doesnt work Edited January 4, 2023 by Linuxuser1234 Share this post Link to post
Linuxuser1234 1 Posted January 4, 2023 (edited) . Edited January 4, 2023 by Linuxuser1234 Share this post Link to post
programmerdelphi2k 237 Posted January 4, 2023 (edited) Sure what: procedure TForm1.ComboEdit1Change(Sender: TObject); var i: integer; begin i := ComboEdit2.Items.IndexOf(ComboEdit1.Items[ComboEdit1.ItemIndex]); if i = -1 then begin ComboEdit2.Items.Add(ComboEdit1.Items[ComboEdit1.ItemIndex]); ComboEdit2.ItemIndex := ComboEdit2.Count - 1; end else ComboEdit2.ItemIndex := i; end; //--- procedure TForm1.ComboBox1Click(Sender: TObject); if (ComboBox2.Items.IndexOf(ComboBox1.Items[ComboBox1.ItemIndex]) = -1) then begin ComboBox2.Items.Add(ComboBox1.Items[ComboBox1.ItemIndex]); ComboBox2.ItemIndex := ComboBox2.GetCount-1 end; // procedure TForm1.ListBox1Click(Sender: TObject); begin if (ListBox2.Items.IndexOf(ListBox1.Items[ListBox1.ItemIndex]) = -1) then ListBox2.Items.Add(ListBox1.Items[ListBox1.ItemIndex]); end; Edited January 4, 2023 by programmerdelphi2k Share this post Link to post
Linuxuser1234 1 Posted January 4, 2023 @programmerdelphi2ki get this error TComboEdit does not contain GetCound and yes i have tried var Share this post Link to post
programmerdelphi2k 237 Posted January 4, 2023 (edited) 36 minutes ago, Linuxuser1234 said: TComboEdit does not contain GetCound and yes i have tried var TComboBox is VCL and use "GetCount" or you can use "ComboBox1.Items.Count" TComboEdit is FMX (your project is FMX then... ) and use "Count" or "ComboEdit1.Items.Count" NOTE: ComboEdit ONCLICK = click on component (into edit control from it), not on "Items" Edited January 4, 2023 by programmerdelphi2k Share this post Link to post
programmerdelphi2k 237 Posted January 4, 2023 (edited) that way it's better: procedure TForm1.ComboEdit1Change(Sender: TObject); var i: integer; begin i := ComboEdit2.Items.IndexOf(ComboEdit1.Items[ComboEdit1.ItemIndex]); if i = -1 then i := ComboEdit2.Items.Add(ComboEdit1.Items[ComboEdit1.ItemIndex]); // ComboEdit2.ItemIndex := i; end; Edited January 4, 2023 by programmerdelphi2k 1 Share this post Link to post
programmerdelphi2k 237 Posted January 4, 2023 NOTE 2: you are ADD value in same ComboEdit2... with ComboEdit2 ??? Share this post Link to post
Lars Fosdal 1792 Posted January 5, 2023 Well, I should also pay better attention to details. My initial reply was VCL code, not an FMX code. My apologies. TComboEdit.OnChange handler procedure TForm2.ComboEdit1Change(Sender: TObject); begin if ComboEdit2.Items.IndexOf(ComboEdit1.Text) < 0 then ComboEdit2.Items.Add(ComboEdit1.Text); ComboEdit2.ItemIndex := ComboEdit2.Items.IndexOf(ComboEdit1.Text); end; Share this post Link to post
programmerdelphi2k 237 Posted January 5, 2023 Really details it's important, sometimes I dont see it.. Share this post Link to post