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.
how to search a listbox
Page 1 of 14 Replies - 511 Views - Last Post: 07 March 2010 - 04:34 AM
Replies To: how to search a listbox
#2
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.
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.
#3
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.
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.
#4
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.
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".
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".
#5
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
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|