Article ID: 223078 - Last Review: October 15, 2002 - Revision: 1.1

FIX: DataGrid Column Widths Incorrect When Using MDAC 2.1

This article was previously published under Q223078

On This Page

Expand all | Collapse all

SYMPTOMS

The width of a DataGrid column bound to an ADO field of type adBSTR is very narrow under MDAC 2.1 compared to the width of an adBSTR column under MDAC 2.0.

CAUSE

A bug fix in MDAC 2.1 changed the return value for GetColumnInfo calls on columns of type adBSTR. This fix exposed a limitation in the DataGrid control(MSDATGRD.OCX).

STATUS

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

This bug was corrected in Visual Studio 6.0 Service Pack 3. For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why  (http://support.microsoft.com/kb/194022/EN-US/ )

194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed  (http://support.microsoft.com/kb/194295/EN-US/ )

MORE INFORMATION

Steps to Reproduce Behavior

To create this project, you must have MDAC 2.1 installed.
  1. Start Visual Basic 6.0.
  2. Create a Standard EXE project. Form1 is created by default.
  3. Add the following Project References:
    Microsoft ActiveX Data Objects 2.1 Library
  4. Add the following Project Components:
    Microsoft DataGrid Control 6.0 (OLEDB)
  5. Add the following control to Form1:
    1 - Microsoft DataGrid Control 6.0 (OLEDB)
  6. Paste the following code into Form1's Code Window:
    Private rs As ADODB.Recordset
    
    Private Sub Form_Load()
    
        'Create a new empty recordset with six fields
        Set rs = New ADODB.Recordset
        
        With rs
           .Fields.Append "Column1", adBSTR, 25
           .Fields.Append "Column2", adInteger
           .Fields.Append "Column3", adBSTR, 25
           .Fields.Append "Column4", adVarChar, 25
           .Fields.Append "Column5", adBSTR, 25
           .Fields.Append "Column6", adDBTimeStamp, 25
           .Open
        End With
       
       'Bind the DataGrid to the new empty recordset
        Set Me.DataGrid1.DataSource = rs
    
    End Sub
    					
  7. Run the project. Note the narrow widths of Column1, Column3, and Column5, which display the adBSTR fields.

APPLIES TO
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
Keywords: 
kbbug kbctrl kbfix kbvs600sp3fix KB223078
 

Article Translations