add/delete items combobox!

Hello !
I'm working with combobox.I add items in  to combobox :
Combobox.items.add(' teacher');
Combobox.items.add(' subject');
Combobox.items.add(' mark');
after that with  itemindex=0--->combobox.text='teacher'
                     itemindex=1---->combobox.text='subject'
                     itemindex=2---->combobox.text='subject'
i have question.How can i remove from combobox 'subject'?
Then if i wan't to add again item 'subject' in to combobox with itemindex=1.how can i do?
thanks!
ongchu001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AmitGKCommented:
       'Add items to combobox
        ComboBox1.Items.Add("teacher")
        ComboBox1.Items.Add("subject")
        ComboBox1.Items.Add("mark")

        'Remove item "subject" from combobox
        For i As Integer = 0 To ComboBox1.Items.Count - 1
            If ComboBox1.Items(i).ToString = "subject" Then
                ComboBox1.Items.RemoveAt(i)
                Exit For
            End If
        Next

        'Insert Item "subject" at desired index in a combo box
        Dim InsertItemAtIndex As Integer = 1
        ComboBox1.Items.Insert(InsertItemAtIndex, "subject")
0
Emmanuel PASQUIERFreelance Project ManagerCommented:
AmitGK, that is VB code.

Ok, it's almost the same in Delphi :

- Delete an item using position :
Combo.Items.Delete(1);

- Delete an item using text value :
Combo.Items.Delete(Combo.Items.IndexOf('subject'));
which can also be written :
With Combo.Items do Delete(IndexOf('subject'));

- Insert item at a specific position :
Combo.Items.Insert(1,'subject');

- insert item only if not found :
With Combo.Items do if IndexOf('subject')<0 Then Insert(1,'Subject');


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.