Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can you help me please?
I have that part of code in Visual Basic made in visual Studio 2012..But it shows an error that: " 'AddItem' is not member of 'System.Windows.Forms.ComboBox'. "

What can I do to fix it and add item to combobox?


here is the code:

VB
ComboBox1.AddItem("4")
        ComboBox1.AddItem("5")
        ComboBox1.AddItem("6")
        ComboBox1.AddItem("7")
        ComboBox1.AddItem("8")
        ComboBox1.AddItem("9")
        ComboBox1.AddItem("10")
        ComoBox1.ListIndex = 0
Posted
Comments
Sergey Alexandrovich Kryukov 17-Jan-13 16:56pm    
Please stop re-posts. You need to follow-up with all your related question on the same page of your original post.
—SA

1 solution

It isn't! :laugh: It's a property of the Items collection.
Try:
VB
ComboBox1.Items.Add("4")
ComboBox1.Items.Add("5")
ComboBox1.Items.Add("6")
ComboBox1.Items.Add("7")
ComboBox1.Items.Add("8")
ComboBox1.Items.Add("9")
ComboBox1.Items.Add("10")
ComoBox1.ListIndex = 0
 
Share this answer
 
v3
Comments
San Dra 17-Jan-13 15:51pm    
Ok :)
San Dra 17-Jan-13 15:53pm    
Still the same error, so I tried this and it worked:



ComboBox1.Items.Add("4")
ComboBox1.Items.Add("5")
ComboBox1.Items.Add("6")
ComboBox1.Items.Add("7")
ComboBox1.Items.Add("8")
ComboBox1.Items.Add("9")
ComboBox1.Items.Add("10")
ComoBox1.ListIndex = 0
OriginalGriff 17-Jan-13 16:23pm    
You're right - there is no AddItem method. c*** up on my part, I didn't remember to change it. Coffee! Coffee! I need coffee...
:laugh:
San Dra 17-Jan-13 16:41pm    
ahahah you're funny :D

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