Microsoft KB Archive/305101

= BUG: Visual Basic Modal Form Freezes When It Is Called from the Click Event of a DataGrid Control =

Article ID: 305101

Article Last Modified on 6/28/2004

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition Service Pack 3
 * Microsoft Visual Basic 6.0 Enterprise Edition Service Pack 4
 * Microsoft Visual Basic 6.0 Enterprise Edition Service Pack 5

-



This article was previously published under Q305101



SYMPTOMS
When you open a Visual Basic form as modal on the Click event of a DataGrid control, if you click on the header section instead of the grid cells, the form freezes. This problem does not occur if you click on the grid cells.



RESOLUTION
To work around this problem, disable the grid on the Click event, and enable the grid on the modal form's Unload event.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Create a new Standard EXE project in Visual Basic. Create two forms (Form1 and Form2). From the Project menu, click Components, and select the Microsoft ADO Data Control 6.0 (OLEDB) and Microsoft DataGrid Control 6.0 (OLEDB) check boxes. Add the following controls to Form1:  Microsoft ADO Data Control 6.0 (OLEDB) Microsoft DataGrid Control 6.0 (OLEDB)</ul>

</li>  Paste the following code into the code window of Form1: Private Sub DataGrid1_Click 'Me.DataGrid1.Enabled = False Form2.Show vbModal End Sub </li>  Paste the following code into the code window of Form2: Private Sub Form_Unload(Cancel As Integer) Form1.DataGrid1.Enabled = True End Sub </li> Run the project, and click on the header of the DataGrid. Notice that the application freezes.</li> To work around this problem, uncomment the &quot;Me.DataGrid1.Enabled = False&quot; line in the &quot;DataGrid1_Click&quot; event of Form1, and run the project again.</li></ol>

Keywords: kbbug kbpending KB305101

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.