Click here to Skip to main content
15,904,817 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
foreach (ListItem li in ListBox.Items)
              {
                  if (li.Selected == true)
                  {
                      // what ever you want to assign to TextBox
                      Name = li.Text = "";

                      ProductNumber = li.Text = "";


                      ListPrice = li.Text = "";
                      Color = li.Text = "";
                      MoreInfo = li.Text = "";

                      Name=li.Text=li.Text+



                  }


i have written like this but i am not sure what to write in the code,
i want to when i select in item in the listbox i have written
C#
if (ListBox.SelectedItem != null)
                    Name = ListBox.SelectedItem.Text;


then the code that i writted first i want to when u select an item in the listbox show all in the info in the textboxes , so my problem is that i dont really know what to write in my foreach loop!
Posted
Comments
[no name] 29-Nov-12 5:36am    
what are you trying to achieve here ?
Kurac1 29-Nov-12 5:37am    
Hi!
I want to put the selected item in the textboxes
Kurac1 29-Nov-12 5:38am    
But i can only reach the names of them not the textboxes
[no name] 29-Nov-12 5:41am    
do you want to update the textbox at every selected item of list box ??
Kurac1 29-Nov-12 5:42am    
Yes exactly!

1 solution

C#
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
       {
           textBox1.Text= listBox1.SelectedItem.ToString();
       }
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900