8 Replies - 2057 Views - Last Post: 02 January 2013 - 01:00 PM Rate Topic: -----

#1 jeffrey4u  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 26
  • Joined: 11-February 09

How to set Combo box Item index

Posted 27 December 2012 - 03:54 PM

Suppose i have this line of code

Me.ComboBox1.Items.Insert(0, ("Zion"))
Me.ComboBox1.Items.Insert(1, "Able")
Me.ComboBox1.Items.Insert(2, "Dan")
Me.ComboBox1.Items.Insert(3, "Moses")

ComboBox1.selectedindex=0
ComboBox1.sorted=true


NB: my aim is to keep 'Zion' on top of the list in the combo box after
the combo box is sorted.
Hope i made myself clear

Is This A Good Question/Topic? 0
  • +

Replies To: How to set Combo box Item index

#2 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,501
  • Joined: 16-March 11

Re: How to set Combo box Item index

Posted 27 December 2012 - 04:05 PM

First when you add an item you should use the add method. After you've done that, and it's been sorted, then use the insert zion at index 0.
Was This Post Helpful? 0
  • +
  • -

#3 jeffrey4u  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 26
  • Joined: 11-February 09

Re: How to set Combo box Item index

Posted 27 December 2012 - 04:12 PM

Tried but not working
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3242
  • View blog
  • Posts: 10,877
  • Joined: 12-December 12

Re: How to set Combo box Item index

Posted 27 December 2012 - 04:13 PM

After your sort sequence has finished you could remove and re-insert 'Zion':

Me.ComboBox1.Items.Remove("Zion")
Me.ComboBox1.Insert(0, "Zion")

Was This Post Helpful? 0
  • +
  • -

#5 jeffrey4u  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 26
  • Joined: 11-February 09

Re: How to set Combo box Item index

Posted 27 December 2012 - 04:20 PM

Don't seem to work either
Was This Post Helpful? 0
  • +
  • -

#6 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: How to set Combo box Item index

Posted 27 December 2012 - 09:06 PM

View Postjeffrey4u, on 27 December 2012 - 05:20 PM, said:

Don't seem to work either

If your ComboBox1.Sorted is still True, then it will just re-sort.

Set ComboBox1.Sorted = False, then insert.
Was This Post Helpful? 0
  • +
  • -

#7 billyboy630  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 94
  • Joined: 09-October 09

Re: How to set Combo box Item index

Posted 28 December 2012 - 11:59 AM

I beleive this was asked and answered on another forum
Was This Post Helpful? 0
  • +
  • -

#8 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,501
  • Joined: 16-March 11

Re: How to set Combo box Item index

Posted 28 December 2012 - 12:31 PM

Why don't you post a link to it
Was This Post Helpful? 0
  • +
  • -

#9 billyboy630  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 94
  • Joined: 09-October 09

Re: How to set Combo box Item index

Posted 02 January 2013 - 01:00 PM

http://www.vbforums....-box-Item-index
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1