Populate selected value of list box to a text box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AarthiVedhavalli
    New Member
    • Aug 2008
    • 5

    Populate selected value of list box to a text box

    Hi,

    In my C# web application I have a list box whic is binded to database.
    What i need now is , if i double click a value in list box that vale should be added to a dropdown list..
    Any suggestions??
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    A listbox has an event of "doubleclic ked" and a property of .SelectedItem

    So you need a method that runs for the doubleclicked event that makes use of the .SelectedItem property.

    Code:
            private void listBox1_DoubleClick(object sender, EventArgs e)
            {
                string TheName = listBox1.SelectedItem as string;
                MessageBox.Show(TheName);
            }
    What you do in that method is up to you. Here I have a MessagBox pop up to show it works. According to your title you want to take that string and put it into the .Text property of a TextBox.

    Comment

    Working...