dxcypt 0 Report post Posted November 4, 2008 (edited) Perlukan bantuan tentang code dan cara menghubungkan 2 ComboBox berkaitan dalam Visual Basic.contoh apabila item di ComboBox1 di klik, ComboBox2 akan memaparkan item yang berbeza.Ada sesiapa dpt tlg? Edited November 4, 2008 by dxcypt Quote Share this post Link to post Share on other sites
sworn 0 Report post Posted November 4, 2008 item yg berbeza?berbeza dgn ape? Quote Share this post Link to post Share on other sites
dxcypt 0 Report post Posted November 4, 2008 Contoh apabila item1 dalam ComboBox1 dipilih, ComboBox2 memaparkan senarai 1, 2, 3..Dan apabila item2 dalam ComboBox1 dipilih, ComboBox2 memaparkan senarai 4, 5, 6..Maksud saya, nilai dalam ComboBox2 bagi setiap item dalam ComboBox1 adalah berbeza..So bagaimana nak hubungkaitkan kedua-dua ComboBox ni.. Quote Share this post Link to post Share on other sites
sworn 0 Report post Posted November 4, 2008 (edited) maknanye mcm.... if combo1.selected = item1 then combo2.items = 1,2,3 if combo1.selected = item2 then combo2.items = 4,5,6 ??camtu ke yg ko tanye?value dlm combo2 tu kita dpt dari mana?ke ko maksudkan bila kita pilih no 3 la katakan kat combo1,kita xnak ade no 3 kat combo2? Edited November 4, 2008 by sworn Quote Share this post Link to post Share on other sites
dxcypt 0 Report post Posted November 4, 2008 value dalam combo2 tu nk tulis sendiri dalam Stringya, kalau pilih no 3 dari combo1, value kt combo2 keluar lain dari value no1 dan no2 dari combo1harap dapat bantu sayathx for reply Quote Share this post Link to post Share on other sites
sworn 0 Report post Posted November 5, 2008 (edited) aku kurang fhm yg mana satu ko nak sbenarnye.so,aku bantai je la buat ye,harap2 menjawab soalan.items kat combo1 aku xtau ko dpt dari mana,so,aku letak je value 1 sampai 6pastu aku buat utk 2 situasi... A== kalo kita pilih num 3 dari combo1,value selain daripada 3 akan kuar kat combo2(1,2,4,5,6).... Dim i As Integer i = 0 Do While (i < ComboBox1.Items.Count()) If (ComboBox1.SelectedIndex <> i) Then ComboBox2.Items.Add(ComboBox1.Items.Item(i)) End If i = i + 1 Loop B== kalo kita pilih num 3 dari combo1,value selepas dari num 3 akan kuar kat combo2(3,4,5,6) Dim i As Integer i = ComboBox1.SelectedIndex Do While (i < ComboBox1.Items.Count()) ComboBox2.Items.Add(ComboBox1.Items.Item(i)) i = i + 1 Loopbetul ke ko nak camni? Edited November 5, 2008 by sworn Quote Share this post Link to post Share on other sites
dxcypt 0 Report post Posted November 5, 2008 (edited) saya dah dapat, saya gunakanDim ch1 As Stringch1 = "Welcome"ComboBox2.Items.Clear()ComboBox2.Items.Add(ch1) 'saya cuma nk paparkan value selain dari ComboBox1thx a lot sworn for help me! Edited November 5, 2008 by dxcypt Quote Share this post Link to post Share on other sites
sworn 0 Report post Posted November 5, 2008 walopun aku xphm ape yg ko maksudkan "value selain" tu,xpela,asalkan dah bleh jln. Quote Share this post Link to post Share on other sites
aem1354 0 Report post Posted November 5, 2008 soalan sket..aku ni mmg suka berty layan je la..heheh...kalo ko uatDim ch1 As Stringch1 = "Welcome"ComboBox2.Items.Clear()ComboBox2.Items.Add(ch1) nilai comboBox2 akan ade Welcome je la..bukkanye apa yg ada kat comboBox1 yang x diselect Quote Share this post Link to post Share on other sites
dxcypt 0 Report post Posted November 5, 2008 ya, bukan value kt ComboBox1, cuma nak paparkan value sendiri kt ComboBox2 lepas ComboBox1 dipilih. Quote Share this post Link to post Share on other sites
sworn 0 Report post Posted November 5, 2008 aku setuju ngan aem1354. tapi,mcm yg aku kate la,walopun aku xphm,tapi asalkan app dia bleh run ikut yg dia nak,jadi le.... Quote Share this post Link to post Share on other sites
aem1354 0 Report post Posted November 5, 2008 sworn ty sket ye... the code yg ko bagi (A) aku rasa dah betul tapi y still kuar the same list dalam comboBox1 n ComboBox2 Quote Share this post Link to post Share on other sites
sworn 0 Report post Posted November 5, 2008 (edited) aku rasa tak.sbab kalo ikut lojiknye...kalo kita tgk kat sini.."If (ComboBox1.SelectedIndex <> i) Then"......kita check kalo index utk item kat combo1 tu xsama dgn index sekarang,baru kita tambah item tu kat combo2..."ComboBox2.Items.Add(ComboBox1.Items.Item(i))"aku try run lg skali td,elok je.aku rasa ko tak select lg item kat combo1 tu kot.sbab kita kan check "combo1.selectedindex".yap....aku try run trus tanpa select item,mmg kuar value same je dua2.ko ltk coding tu kat combobox1_selectedIndexChanged la lg senang.supaya dia trigger kalo kita select item je. Edited November 5, 2008 by sworn Quote Share this post Link to post Share on other sites
aem1354 0 Report post Posted November 5, 2008 (edited) aku letak kat load tadi.. yup mmg jadi.. tankz...tp y kene ade i=i+1.. aku rasa ni bleh jadi kan list tu bertambah lagi je?so aku use ComboBox2.Items.Clear() kAt atas ...so baru lah ianya menjadi..dah macam aku plak yg mintak toolonlg ni..hheheh. Edited November 5, 2008 by aem1354 Quote Share this post Link to post Share on other sites