Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
How do I set up a program to when a user enters something into a text box,click a button, then it shows up in a list box?
 
Improved Question:
Alright,that's been solved. That was only a small part of this,as when someone clicks an item in the list box(right now theres only one there,"example1",when they click it,it shows on the right the account name"example1",the User Name "potato" and password,"pickle". The example one was already set by me,but if someone adds a new item to the list box,how would I set it up to where they can also add a log in and password,to where if they click one that they added,that it will also show a username and password next to it?
Posted 7-Oct-12 7:23am
Edited 7-Oct-12 8:18am
v2
Comments
Sandeep Mewara at 7-Oct-12 13:24pm
   
Insert the texted item into the list box in button click event?
Devin Halbert at 7-Oct-12 13:26pm
   
Wait so would this work?(lbx=List Box,tbx=Text Box)
lbxAccounts.SelectedItem = tbxNewAccountName.Text
Sandeep Mewara at 7-Oct-12 13:30pm
   
No it would not. You need to create a new item and then set the item as text data and then add the item to listbox.
Wes Aday at 7-Oct-12 13:30pm
   
http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.items.aspx
Devin Halbert at 7-Oct-12 13:32pm
   
You must be a pc god,you have answered 3 of my 3 questions I have asked :D
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Follow the following coding:
 
lbx.Items.Add(tbx.Text);
 
Add the above code in your button's click event.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Try this code:
Private Sub button1_Click(sender As Object, e As EventArgs)
    listBox1.Items.Add(textBox1.Text)
End Sub
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 321
1 Sergey Alexandrovich Kryukov 286
2 RyanDev 75
3 PhilLenoir 70
4 nv3 60
0 Sergey Alexandrovich Kryukov 6,691
1 OriginalGriff 6,119
2 CPallini 2,473
3 Richard MacCutchan 1,697
4 Abhinav S 1,560


Advertise | Privacy | Mobile
Web01 | 2.8.140821.2 | Last Updated 7 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100