Microsoft KB Archive/252702

{|
 * width="100%"|

BUG: Split Causes DataGrid to Repaint Itself Continuously

 * }

Q252702

-

The information in this article applies to:


 * Microsoft Visual Basic Professional Edition for Windows, version 6.0
 * Microsoft Visual Basic Enterprise Edition for Windows, version 6.0
 * ActiveX Data Objects (ADO), versions 2.0, 2.1 SP2, 2.5, 2.6

-

SYMPTOMS
Using splits can cause the DataGrid control to repaint itself continuously when the Scrollbar property is set to dbgAutomatic. This behavior causes CPU utilization to remain at 100 percent.

RESOLUTION
The workaround for this bug is to set the Scrollbar property to something other than dbgAutomatic. Using dbgBoth, dbgNone, dbgHorizontal, or dbgVertical displays the grid without continuously repainting. The Scrollbar property can be changed at design time using the DataGrid's property pages. It can also be set in code prior to displaying the DataGrid.

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

Steps to Reproduce Behavior
Create a new Standard EXE in Visual Basic. Form1 is created by default.

One the Project menu, select References and select Microsoft ActiveX Data Objects Library.

On the Project menu, select Components, and then select the following components:


 * Microsoft DataGrid Control 6.0 (OLEDB)
 * Microsoft ADO Data Control 6.0 (OLEDB)

Place an ADO Data Control (Adodc1) on Form1 and set the following properties:

ConnectionString: Enter a valid Northwind connection

CursorLocation: adUseClient

RecordSource: SELECT * FROM Employees Place a DataGrid (DataGrid1) on the form and set the following properties:

"DataSource: Adodc1" Add a Command (Command1) button and the following code to the Form:

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(1).Columns(0).Visible = False For I = 1 To .Splits(1).Columns.Count - 1 .Splits(1).Columns(I).Visible = True Next I '     .ScrollBars = dbgHorizontal End With End Sub

Private Sub Form_Load Command1.Caption = "Show Split" End Sub Run the code. Note that clicking the Command button splits the grid. Also, CPU utilization goes to 100 percent and the DataGrid flickers. Sizing the grid might cause the scrollbar to redraw incorrectly.

End the application and uncomment the line explicitly setting the ScrollBar property of the grid. Re-run the application and note that the grid split is displayed properly.

© Microsoft Corporation 2000, All Rights Reserved.

Contributions by Robert Pajaro, Microsoft Corporation

Additional query words:

Keywords : kbADO kbDatabase kbDataBinding kbVBp600 kbVBp600bug kbGrpDSVBDB kbGrpDSMDAC kbDSupport kbADO250 kbMDAC260 kbADO260 kbMDACNoSweep

Issue type : kbbug

Technology : kbVBSearch kbAudDeveloper kbADOsearch kbADO200 kbADO210sp2 kbADO250 kbADO260 kbZNotKeyword6 kbZNotKeyword2 kbVB600Search kbVBA600 kbVB600