OneByte_ OneByte_ - 1 year ago 107 Question

Can't add items to ListView after ListView.Clear

So, I'm currently working on a game called

, 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
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
are gone.

Here's the code:
- The important
for this issue are called
, which is triggered when you click the bank button on the main page, and
, which is triggered when you click the home button on the bank page.

Any help would be apprechiated!

Mika // OneByte_

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download