By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,780 Members | 1,549 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,780 IT Pros & Developers. It's quick & easy.

Populate selected value of list box to a text box

P: 5
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??
Aug 21 '08 #1
Share this Question
Share on Google+
1 Reply


tlhintoq
Expert 2.5K+
P: 3,525
A listbox has an event of "doubleclicked" and a property of .SelectedItem

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

Expand|Select|Wrap|Line Numbers
  1.         private void listBox1_DoubleClick(object sender, EventArgs e)
  2.         {
  3.             string TheName = listBox1.SelectedItem as string;
  4.             MessageBox.Show(TheName);
  5.         }
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.
Aug 22 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.