ListBox Help

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
16 posts Page 2 of 2
Contributors
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: ListBox Help
mandai
A listview doesen't contain a property for SelectedIndex since you can select multiple items, there is an array called SelectedIndecies for that. Try
Code: Select all
Dim i As Integer = ListView1.SelectedIndices(0)
If you remove an item from a listview then that item's subitems will also be removed.

If you want to add those to a listview you would use:
Code: Select all
ListView1.Items.Clear()

        My.Settings.BKDocTitle.Add(CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle)

        For i As Integer = 0 To My.Settings.BKDocTitle.Count - 1
            ListView1.Items.Add(New ListViewItem(New String() {My.Settings.Bookmarks(i), My.Settings.BKDocTitle(i)}))
        Next
User avatar
harmeister
VIP - Donator
VIP - Donator
Posts: 26
Joined: Fri Jul 23, 2010 1:21 am

Re: ListBox Help
harmeister
Oh Wow never thought of it like that, but I also have a question and it does relate to the listbox/listview but also with tool bars. I have been poking around the forums of many different websites learn some pretty fricken awesome new things but this time I found like 3 to 4 post of generally the same thing on different websites so here is my question. You know how internet explorer can add bkmks to the toolbar instantly with the name of the page and the icon as well I know that is a tool bar but what some people suggest is that you try to add a setting each time u hit add new favorite and it just copies the name and stuff to the setting and it does the rest is there a way to do this and I also have an off topic question but would seem pointlesss to make a brand new post just for a small question. My combobox for the url address will not change when I switch tabs for instance: I type in www.google.com in one tab but when I open a new tab it still says www.google.com now if I type in www.msn.com and I switch to the google tab it says www.msn.com how do I fix this or can it be fixed?
Sincerely,
Harley
[Information Technologist in training, New to the whole VB coding]
User avatar
harmeister
VIP - Donator
VIP - Donator
Posts: 26
Joined: Fri Jul 23, 2010 1:21 am

Re: ListBox Help
harmeister
mandai wrote:
A listview doesen't contain a property for SelectedIndex since you can select multiple items, there is an array called SelectedIndecies for that. Try
Code: Select all
Dim i As Integer = ListView1.SelectedIndices(0)
If you remove an item from a listview then that item's subitems will also be removed.

If you want to add those to a listview you would use:
Code: Select all
ListView1.Items.Clear()

        My.Settings.BKDocTitle.Add(CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle)

        For i As Integer = 0 To My.Settings.BKDocTitle.Count - 1
            ListView1.Items.Add(New ListViewItem(New String() {My.Settings.Bookmarks(i), My.Settings.BKDocTitle(i)}))
        Next

Another question I would use this to remove as well or just to add and if so what do I do to get it to remove?
Sincerely,
Harley
[Information Technologist in training, New to the whole VB coding]
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: ListBox Help
mandai
That code does use ListView1.Items.Clear() to remove all items but you can also use ListView1.Items.RemoveAt(index) to remove an item at a specified index.
User avatar
harmeister
VIP - Donator
VIP - Donator
Posts: 26
Joined: Fri Jul 23, 2010 1:21 am

Re: ListBox Help
harmeister
I am sorry Visual Basic 2010 is a little touchy. I tried to split this into button form so can you help me out? Can the code above be translated for buttons such as add bookmark, remove selected bookmark, remove all. And when I do the double click option how do I make it to where it will navigate to the url in the url column and not the page title because everything or code I used kept going to the page title. How do I make it work?
Sincerely,
Harley
[Information Technologist in training, New to the whole VB coding]
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: ListBox Help
mandai
I'm sure there are plenty of examples around the forum on how to do this.
16 posts Page 2 of 2
Return to “Tutorial Requests”