Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB VisualStudio2012
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:
 
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 17-Jan-13 10:40am
San Dra391
Comments
Sergey Alexandrovich Kryukov at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It isn't! Laugh | :laugh: It's a property of the Items collection.
Try:
        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
  Permalink  
v3
Comments
San Dra at 17-Jan-13 15:51pm
   
Ok :)
San Dra at 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 at 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 at 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)

  Print Answers RSS
0 OriginalGriff 7,205
1 DamithSL 5,114
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,747
4 Kornfeld Eliyahu Peter 4,474


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 17 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100