Microsoft KB Archive/251292: Difference between revisions
From BetaArchive Wiki
(importing KB archive) |
(No difference)
|
Revision as of 17:15, 18 July 2020
Article ID: 251292
Article Last Modified on 5/12/2003
APPLIES TO
- Microsoft Visual Basic 6.0 Learning Edition
- Microsoft Visual Basic 6.0 Professional Edition
- Microsoft Visual Basic 6.0 Enterprise Edition
This article was previously published under Q251292
SYMPTOMS
An application error occurs when a modal dialog or form is closed after being shown from the ItemClick event of a ListView control in Microsoft Visual Basic. The error only occurs if the ListView control is cleared in the ItemClick event and an item other than the first item in the ListView was clicked.
RESOLUTION
To work around this behavior, the ListView control must be disabled before it is cleared. Once the ListView is cleared, the control can then be enabled.
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem) ListView1.Enabled = False ListView1.ListItems.Clear ListView1.Enabled = True MsgBox "Cleared" End Sub
MORE INFORMATION
Steps to Reproduce Behavior
- Start a new Visual Basic Standard EXE project. Form1 is created by default.
- On the Project menu, select Components. In the Components dialog box, select the Microsoft Windows Common Controls 6.0 component and click OK.
- Add a ListView control to Form1.
Add the following code to the General Declarations section of Form1:
Private Sub Form_Load() ListView1.ListItems.Add , , "First" ListView1.ListItems.Add , , "Second" End Sub Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem) ListView1.ListItems.Clear MsgBox "Cleared" End Sub
- Press the F5 key to run the program.
- Click on the word "Second" that is contained within the ListView control. Notice that the message box dialog is displayed.
- Close the dialog box and note that an Application Error occurs.
Keywords: kbbug kbnofix kblistview kbprb kbctrl kbcontrol KB251292