Microsoft KB Archive/306886

= BUG: Split Causes DataGrid to Repaint Itself Continuously =

Article ID: 306886

Article Last Modified on 12/6/2001

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Professional Edition

-



This article was previously published under Q306886





SYMPTOMS
When you use the Splits property, if you set the ScrollBar property to dbgAutomatic, the DataGrid control may repaint itself continuously.

This behavior causes CPU utilization to remain at 100 percent. Under certain circumstances, you receive the following error message:

Run-time Error 28 &quot;Out of Stack Space&quot;

The application quits, and the Visual Basic Integrated Development Environment (IDE) closes unexpectedly.



RESOLUTION
To work around this problem, set the ScrollBar property for each Splits property to dbgBoth.

If you set ScrollBar to dbgAutomatic, dbgNone, or dbgVertical, the grid is displayed and continuously repainted until you receive the &quot;Out of Stack Space&quot; error message. If you use the dbgHorizontal setting, you do not receive the same error message consistently. If you use the dbgHorizontal setting, sometimes the CPU utilization remains at 100 percent.

You can use the property pages of the DataGrid control to change the ScrollBar property at design time. You can also set this property in code before you display the DataGrid.



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 in Visual Basic. Form1 is created by default. On the Project menu, click References, and select the Microsoft ActiveX Data Objects Library check box. On the Project menu, click Components, and then select the following components:  Microsoft DataGrid Control 6.0 (OLEDB) Microsoft ADO Data Control 6.0 (OLEDB)</li></ul>

</li> Place an ADO Data Control on Form1. Adodc1 is added by default. Set the following properties for Adodc1:

ConnectionString: Type a valid Northwind database connection

CursorLocation: adUseClient

RecordSource: SELECT * FROM Employees

</li> Place a DataGrid on Form1. DataGrid1 is added by default. Set the following properties for DataGrid1:

DataSource: Adodc1

</li>  Place a Command button on Form1. Command1 is added by default. Add the following code to Form1: Option Explicit

Private Sub Command1_Click Dim I As Integer With DataGrid1 For I = 1 To .Splits(0).Columns.Count - 1 .Splits(0).Columns(I).Visible = False Next I        .Splits.Add (1) '.Splits(0).ScrollBars = dbgBoth .Splits(1).Columns(0).Visible = False For I = 1 To .Splits(1).Columns.Count - 1 .Splits(1).Columns(I).Visible = True Next I        '.Splits(1).ScrollBars = dbgBoth End With End Sub

Private Sub Form_Load Command1.Caption = &quot;Show Split&quot; End Sub </li> Run the code. Click Show Split to split the grid.

Notice that CPU utilization is 100 percent, and the DataGrid flickers. If you try to size the grid, the scroll bar may redraw incorrectly. You receive the above-mentioned error message, and the Visual Basic IDE stops responding and then closes unexpectedly.</li>  Stop the application, and uncomment the two lines that explicitly set the ScrollBar property of each of the splits. '.Splits(0).ScrollBars = dbgBoth

-and-

'.Splits(1).ScrollBars = dbgBoth </li> Run the application again. Notice that the grid is split properly.</li></ol>

Additional query words: CPU 100% Run-time Error 28

Keywords: kbbug kbmdacnosweep kbpending KB306886

-

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

© Microsoft Corporation. All rights reserved.