Friday, February 4, 2011

TrueDBGrid Not Clearing Last Row

I have a TrueDBGrid that is bound to an XArray in Visual Basic 6 (VB6).  I was finding that when I would delete all the rows from the XArray and rebind to the TrueDBGrid the grid would still contain the data, even though the XArray did not.  After spending hours trying every property and method of the TrueDBGrid and the XArray I finally stumbled across a way that worked.

I was clearing the array that was previously assigned to the grid and then rebinding the grid, but the grid wasn't updating.

Original Code:

    xaData.Clear
    tdbGrid.ReBind

I found that even though the TrueDBGrid's array property had previously set to the XArray it needed to be set again after the clear and then rebound.

New Code:

    xaData.Clear
    tdbGrid.Array = xaData
    tdbGrid.ReBind

No comments: