4 Replies - 511 Views - Last Post: 07 March 2010 - 04:34 AM Rate Topic: -----

#1 clboyrun  Icon User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 14
  • Joined: 19-January 10

how to search a listbox

Posted 04 March 2010 - 06:33 PM

my program adds item's to one listbox, and a bonus to a second. I wondered if you could search the items in the first listbox so i could go to that location in the second listbox and change the bonus. Any help will be appriciated.
Is This A Good Question/Topic? 0
  • +

Replies To: how to search a listbox

#2 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1397
  • View blog
  • Posts: 4,494
  • Joined: 25-September 09

Re: how to search a listbox

Posted 04 March 2010 - 06:42 PM

As per form rules, I cannot supply you with code unless you show some effort on your part by posting some code of your attempt to complete the solution.

However, I can tell you that the listbox has two find methods (findString and FindStringExact) that should help you in your endeavor.

Once you have some code and IF you still, need help, post your attempt and someone can help your further.
Was This Post Helpful? 1
  • +
  • -

#3 clboyrun  Icon User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 14
  • Joined: 19-January 10

Re: how to search a listbox

Posted 04 March 2010 - 07:45 PM

i cannot supply the code that i used being that the computer does not have internet access but it basically is

lboxSkillsNames.Items.Add("Language / English")
lboxSkillsBonus.Items.Add("+ 0")
lboxSkillsNames.Items.Add("Language / Russian")
lboxSkillsBonus.Items.Add("+ 0")
lboxSkillsNames.Items.Add("Language / Spanish")
lboxSkillsBonus.Items.Add("+ 0")

this is one possibility, but later on they might chose to increase the skill to "English" by 1, so i would need to find that location, then go to that item location in the Bonus listbox and add one to the Bonus.
Was This Post Helpful? 0
  • +
  • -

#4 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1397
  • View blog
  • Posts: 4,494
  • Joined: 25-September 09

Re: how to search a listbox

Posted 05 March 2010 - 04:20 AM

OK, that's not really code to attempt the problem but Here's as start.

If the indexes are the same (ie, the first item in lboxSkillsBonus represents the first item in lboxSkillsNames) you can put the following inside. It should be a good start to what you're wanting.
    Private Sub lboxSkillsNames_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lboxSkillsNames.SelectedIndexChanged
        lboxSkillsBonus.SelectedIndex = lboxSkillsNames.SelectedIndex
    End Sub


This will hilight the lboxSkillsBonus item based on the index of the item you select in lboxSkillsNames.

Then from there you can use the .SelectedItem method for the appropriate listbox to determine the "value".
Was This Post Helpful? 1
  • +
  • -

#5 Psyfire  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 29
  • Joined: 23-November 09

Re: how to search a listbox

Posted 07 March 2010 - 04:34 AM

Why not use a Listview control with style set to details, then add 2 columns? Would make life a lot easier
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1