473,396 Members | 1,768 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

To add the string in the text box to a dropdown list or Listbox

Hi All,

I have one more question in my project, Last time the reply I got really helped me a lot . This is the project in WinForm(C#). I want to copy the text in the text box to a dropdownlist or listbox (or any other control) where I can keep adding the string which I enter in my text box everytime? Since I am new to .NET can someone help me with this? Thanks a lot for the help.
Feb 6 '09 #1
1 1854
vekipeki
229 Expert 100+
Where are you stuck exactly?

If you know how to add items to any collection programmatically, then you can easily apply that to any similar control.

Every control that behaves as a "list" (ComboBox, ListBox), usually has a property which implements the IList interface.

If a class implements IList, then it must implement its methods - like Add, Remove, Contains etc. (check ths MSDN documentation for a complete list: IList interface members).

For example, ComboBox.Items is a property which implements the mentioned IList interface. This means that we can add items to that property, using the Add method. Check MSDN for an example: ComboBox.Items.

Expand|Select|Wrap|Line Numbers
  1. myComboBox.Items.Add("some item");
  2. myComboBox.Items.Add("some other item");
If you can add a constant string to your combo box, then you can also add any property which is a string:

Expand|Select|Wrap|Line Numbers
  1. string itemToAdd = myTextBox.Text;
  2. myComboBox.Items.Add(itemToAdd);
Feb 6 '09 #2

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

Similar topics

10
by: J P Singh | last post by:
Hi There We have dropdown on ASP page. The problem is we have about 900 items in the dropdown. Users scrolling through the list have become very frustrated in the past. Can someone suggest...
5
by: Rolan | last post by:
I have tried many iterations of constructing an expanded string link criteria for a list box selection, but have not been successful. The List Box uses a Totals Select Query that has a CustID,...
4
by: Steve Le Monnier | last post by:
I have a textbox with a lookup button facility. What I would like to do is also offer a quick selection facility by having a dropdown list appear under the control once the user has typed a single...
3
by: Lloyd Sheen | last post by:
I have a page that works fine. I am trying to optimize the page by overriding some of the Information that is being saved in the hidden VIEWSTATE. If I make the properties of the dropdown False...
1
by: Yoshitha | last post by:
Hi in my web form i had dropdown list control and using items property i;ve added "--- select Item-----" 0 1
7
by: Peter | last post by:
Does anyone know of a good dropdown WebForm control that works like the Windows Forms dropdown control with type ahead feature, Where user can type in a value and it automatically displays the...
3
by: Kevin Walzer | last post by:
I'm trying to set the active item in a Tkinter listbox to my application's currently-defined default font. Here's how I get the fonts loaded into the listbox: ...
2
by: Tracey | last post by:
How can I convert to a string (what I thought was a string)? and/or How can I assign the value of a selected item in a list box to Label1.Text? using VB in VS2005. Thanks, Tracey I completed...
18
by: Academia | last post by:
I let the use modify the text of a combobox and then I replace the selected item with the new text (in Keyup event). But if he sets the Text property to an empty string ("") that sets the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.