Click here to Skip to main content
15,915,513 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to get all combobox items?
For example my combobox has these items and H need to add all of these items to my richtextbox:
test1
test2
test3
....
Give me some examples.
Thanks
Posted
Updated 8-Aug-13 23:51pm
v3
Comments
[no name] 9-Aug-13 6:24am    
http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.items.aspx
Pouya Mozafar 9-Aug-13 6:53am    
I saw it,But I want to add ALL my combobox items to richtextbox OR add all of them to:
My.Application.Info.DirectoryPath & "\servers\Servers.inf"
How I can do it?
[no name] 9-Aug-13 7:14am    
The Items collection contains ALL of the items already so there is nothing to show you. All you need to do is write a simple loop to add the items to your richtextbox. What exactly is the problem?
Pouya Mozafar 9-Aug-13 7:29am    
And..What is the simple loop?

1 solution

The simple loop is
For Each i as Object in combobox1.Items
     'do something with i.ToString()
Next


You can either append the text to your richtext box or put it straight out to the file. There are many examples of file handling if you google e.g. http://www.techrepublic.com/article/read-and-write-text-files-with-visual-basic-net/[^]

There are also many tutorials on using comboboxes e.g. http://www.tutorialspoint.com/vb.net/vb.net_combobox.htm[^]
 
Share this answer
 
Comments
Pouya Mozafar 9-Aug-13 14:18pm    
You,always answer my question AND YOUR ANSWERS ARE TRUE.
Thanks for your help.

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