Visual Basic 6 - DBGrid, Empty Cells AllowSizing Bug?

Something not .NET related, regarding VB6.

Here is some strange behaviour:

Create a new .EXE project with the following References and Components:

References : Microsoft DAO 3.51 Object Library
Components : Microsoft Data Bound Grid Control 5.0 (SP3)

Add a DBGrid to your form with it's DataSource set to datQuery (Data).

Add a textbox and a button as well, and put this code in it:
1Option Explicit

2
3Private Sub cmdExecute_Click()
4 Call LoadTable(txtquery.Text)
5End Sub
6
7Private Sub LoadTable(strQuery As String)
8 Dim Db As Database, Rs As Recordset
9
10 Set Db = DBEngine.Workspaces(0).OpenDatabase(dbPath)
11 Set Rs = Db.OpenRecordset(strQuery)
12 Rs.MoveLast
13 Rs.MoveFirst
14 Set datQuery.Recordset = Rs
15
16 Me.Caption = "Query - Colums: " & Rs.Fields.Count & " - # Records: " & Rs.RecordCount
17End Sub
18

Run your code, and this is what it should look like:



Now, go to the Custom properties of the DBGrid, to the Layout tab and uncheck 'AllowSizing'.



Run your program again, and now your DBGrid will indicate there are results, but there will be no text, like this:



Why is it doing this? I really have no idea. But the best part is, when you check the AllowSizing property again, it isn't back to normal. It stays broken.

This 'bug' (don't know if it's a bug) was encountered some days ago, I reproduced it this afternoon, and now I installed VS6 SP6, but the bug remains.

If anyone wants a project which has the bug in it, I uploaded something small (30Kb) that got destroyed by this.

Anyone who has encountered this as well? And perhaps has an explenation of why it's doing this.

Update: Just when I posted this and looked at my post again, I noticed something, the second screenshot only had 2 columns, so I realised it did fetch the records, but didn't knew where to display the data. And when you right click and choose 'Clear Fields' it works again. But the AllowSizing is automatically checked on again. To add some value to this post, maybe anyone knows how to uncheck AllowSizing without the grid resetting it's own columns?

1 Comment

Comments have been disabled for this content.