OneByte_ OneByte_ - 6 months ago 23
Vb.net Question

Can't add items to ListView after ListView.Clear

So, I'm currently working on a game called

uToob
, which should be a YouTUbe-Simulation-Kinda game. The game should be realistic, so I programmed a kinda-OS for the game. Now I'm working on the
Internet Explorer
, which should be the web browser. When you open it, there's some
PictureBoxes
you can click to go to different "Websites" using a TabControl. There also is a Bank-Site. The problem is: When I click the Home Button on the bank site, which brings me back to the Main Page, and then go back to the bank page, all the transactions in the
ListView
are gone.

Here's the code: http://pastebin.com/qCWzPVH8
- The important
Subs
for this issue are called
SwitchBank
, which is triggered when you click the bank button on the main page, and
HomeBank
, which is triggered when you click the home button on the bank page.

Any help would be apprechiated!

Mika // OneByte_

Answer

Did you bother to read the relevant documentation? Obviously you didn't. You could have solved this issue for yourself in less than a minute if you had.

You can use this method to remove all items and columns from the ListView control without having to call the individual Clear methods from the ListView.ColumnHeaderCollection and ListView.ListViewItemCollection classes.

Do you want to clear all the columns? I'm guessing not, so why would you call a method that does so? If all you want to do is clear the items then that's what you should do, i.e. call Clear on the Items collection.

In future, make sure you read the relevant documentation first when you have an issue. VS has a Help menu for a reason.