Click here to Skip to main content
15,894,285 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!

I have created a Listbox and textboxes.
The Listbox has Name, ProductNumber, Color, and so on but it only shows the Name.

When I select The Name from the Listbox, I want it to display all the values that are not shown in textboxes. Any help would be very much appreciated. Thanks.

OP's additional information copied from comment below
C#
public void GetMyData(string prod)
{
   TextBox_ProdNum.Text = prod;

   TextBox_Color.Text = prod;
}
Posted
Updated 1-Dec-12 7:51am
v3
Comments
Dominic Abraham 1-Dec-12 11:30am    
Can you give some lines of code what you tried there?
Kurac1 1-Dec-12 11:50am    
public void GetMyData(string prod)
{



TextBox_ProdNum.Text = prod;


TextBox_Color.Text = prod;



}

Hi Kurac,use following demo code...
C#
public partial class Form1 : Form
  {
      private static string[] nameS;
      public Form1()
      {
          InitializeComponent();
          string name = "Shir Visnu Bhagwan";
          nameS = name.Split(' ');
          listBox1.Items.Add(nameS[0]);
        }

      private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
      {
          textBox1.Text = nameS[1];
          textBox2.Text = nameS[2];
      }
  }

C#


and just try once more..
Happy coding :-)
 
Share this answer
 
hi dear,

C#
private void listBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            // your selected value is store in textbox
            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