How do you clear a flex grid so that new data can be added 
Author Message
 How do you clear a flex grid so that new data can be added

What is the proper or good method to clear out a
MSFlexGrid so that new data may be added with the ADD
method?

If I just go through the process of deleting rows from the
bottom up I still have the last non-fixed row to contend
with. How do you get rid of this last or top most row so
that you can add fresh data to the grid without having the
bottom row being the old top row?

Sub ClearGrid(grid As MSFlexGrid)
Dim r As Integer
r = grid.Rows
Dim i As Integer
'
' you need to remove items from the bottom up
'
For i = r To 3 Step -1
grid.RemoveItem i
Next i
'
'clear out the first non-fixedrow
' this just blanks the cells out
' it does not get rid of the row
'
For i = grid.FixedCols To grid.Cols - 1
    grid.TextArray(Fgi(1, i, grid)) = ""
    DoEvents
Next i
End Sub
Function Fgi(r As Integer, c As Integer, grid As
MSFlexGrid) As Integer
    '
    'computes the CELL number for a FlexGrid
    ' given the row and column values
    '
    Fgi = c + grid.Cols * r
    'Debug.Print grid.TextArray(Fgi)
End Function

And then when I do this:
i = 1
If Not (adoRS.EOF Or adoRS.BOF) Then
    Do Until adoRS.EOF
        Data = i & vbTab & adoRS!CoilSpec & vbTab & _
                adoRS!WGN & vbTab & _
                adoRS!REV & vbTab & _
                adoRS!WMW & vbTab & _
                adoRS!WML & vbTab & _
                adoRS!bu & vbTab & _
                adoRS!DIAG
        gridCoilSpecs.AddItem Data, i
        i = i + 1
        adoRS.MoveNext
    Loop
End If

 I end up with the original first row of data on the
bottom of the grid. I can tell it's the original since it
still has the original row number in the fixed col.



Sat, 13 Aug 2005 05:46:37 GMT  
 How do you clear a flex grid so that new data can be added

Quote:
> What is the proper or good method to clear out a
> MSFlexGrid so that new data may be added with the ADD
> method?

<cut>

 Sub ClearGrid(grid As MSFlexGrid)
 grid.Rows = grid.FixedRows
 End Sub



Sat, 13 Aug 2005 07:17:05 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. data grids/ms flex grids

2. How can I refresh data in data grid after add new/edit

3. How can I refresh/requery data in data grid after add new/edit

4. flex grid wont clear

5. flex grid or data grid or neither?

6. flex grid wont clear

7. GRID.VBX....What am I doing wrong.

8. How can i clear the MSHFLEXGRID without CLEAR - Como limpar a GRID sem usar CLEAR

9. How to add a BMP to a cell of MS-Flex Grid

10. Adding Lookup List for columns in Flex Grid.

11. Data Bound Grid VB6 Adding New Records

12. Populating MS Flex Grid w/Data

 

 
Powered by phpBB® Forum Software