Home Forums WinForms controls Other WinForms controls Code Is Not Deleted When SmartItem Is Deleted Reply To: Code Is Not Deleted When SmartItem Is Deleted

User (Old forums)
Member
Post count: 23064

Ok, I have figured out what the problem is. It seems to be a small bug in the deletion of a control.

For example, let’s say you add menu item #1 and menu item #2 to a menu bar. Now you decide to delete both of the items. Before you delete the items, take a look at each item’s name.

For menu item #1, delete it by highlighting the menu item then pressing the delete key. Then for menu item #2, highlight it click the drop-down arrow on the right side of it. Then on the pop up menu, select the Delete menu item.

Now, open up the code view for the form, and expand the “Windows Form Designer generated code” region. Now take a look through the section declaring all the controls on the form. (eg. They all start with “Friend WithEvents”) Once here, scroll towards the bottom of this list of control declarations, and try to find the menu item variables you deleted earlier.

You won’t see menu item #1, because it you deleted it using the normal way of deleting a control. But you will see menu item #2 still being declared for some reason, even though it’s already been deleted of the Designer part of the form. If you look further through the windows designer, you will also see other references to the deleted menu item #2.

So, for now, I would advise no one to delete an object using Delete command in the context menu of an item on the GUI. If so, you’ll just be leaving trash in your form code that is not being used.

Imported from legacy forums. Posted by paulplatter (had 3099 views)