Jump to content
Rickets

[VB]Listbox si textbox

Recommended Posts

Problema sta in felul urmator :

Am 2 textbox-uri si 2 listbox-uri.

Am facut in asa fel incat atunci cand fac click pe un item din listbox1, acesta sa apara in textbox1...

Acum vine intrebarea:

Sa zicem asa

Listbox1:

portocale

banane

mere

pere

Listbox2:

flori

has

tigari

alcool

Bun, am facut click pe al doilea item din listbox1 (banane) si a aparut in textbox1. Vreau ca atunci cand fac chestia asta sa apara si in textbox2 al doilea item din listbox2, adica cand fac click pe un item din primul listbox si apare in primul textbox, sa apara si in al doilea textbox itemul din listbox2 conform indexului itemului pe care l-am selectat din listbox1.

Link to comment
Share on other sites

nu stiu in vb, dar incearca, la event sa iei indexul de la itemul selectat din list1 si sa selectezi itemul din list2 cu acelasi index.

Pseudo cod, int selectat = list1.getSelectedIndex (); list2.setSelectedIndex (selectat);

//Pare rau, am citit din nou si vad ca vrei altceva

Pseudo cod, ideea e cam aceeasi, iei indexul la elementul selectat si il manipulezi cum vrei:

int selectat : list2.getSelectedIndex ();

textbox1.put( (String sau ce ai tu) list1.get(selectat));

textbox2.put( String sau ce ai tu) list2.get(selectat));

daca nici asa nu e ma scuzi ca nu inteleg ce vrei sa faci :-? e si tarziu pt mine

Edited by AdIntended
Link to comment
Share on other sites

@nedo

Eu m-am gandit la asta :

 Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
TextBox1.Text = ListBox1.SelectedItem
Dim k As Integer = ListBox1.SelectedIndex
TextBox2.Text = ListBox2.Items(k)
End Sub

Si merge!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...