Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using a string as an alias/nickname
#2
Hello strawman83,


I think that to resolve this issue you have two reasonable solutions.
1) Create a new ComboBoxItem object that has a "tag" field that contains the text of the blog post. That is, you can do something like this:

Code:
while j < blogLineCount
   blogAlias = blogArray(i).Substring(1,9)
    Dim item as New ComboBoxItem
    item.text = blogAlias
    item.tag = blogArray(i)
   combobox1.Items.Add(item)

Of course, this option is fairly complicated since you will need to make a custom version of the ComboBox object and a new ComboBoxItem class.

2) Make a List that mirrors the ComboBox. This is often the solution that I use to this problem since it is so simple. Your code will then look something like this:

Code:
Dim text as New List<String>()
while j < blogLineCount
    blogAlias = blogArray(i).Substring(1,9)
    comboBox1.Items.Add(blogAlias)
    text.Add(blogArray(i))


' This function is called when the user changes the ComboBox item
Private Sub Item_Changed(ByVal obj as Object, ByVal e as EventArgs) Handles comboBox1.SelectedIndexChanged
    TextBox1.Text = text.Item(comboBox1.SelectedIndex)
End
In this method, the indices of the blog text and the blog "aliases" are synced, so that when the user selects an alias, they are also selecting the index of the corresponding text. I hope this helps!
My Blog | My Setup | My Videos | Have a wonderful day.
Reply


Messages In This Thread
RE: Using a string as an alias/nickname - by brandonio21 - 06-20-2015, 09:00 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)