Delete Null Rows From a Grid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ibrahim2008
    New Member
    • Nov 2008
    • 9

    Delete Null Rows From a Grid

    While filing in a grid,total i am getting 19 rows,from which all 14 rows are
    filing(datas exist),then 15,16,17,18 rows are blank(means null),but then 19th rows are filing.but i don't want these 15,16,17,18 rows.but i need 19 rows

    so how to delete those blank rows,can any one tell how to merge those
    15,16,17,18,19 rows in one rows,but it has to show 19 row data.


    Regards,
    Ibrahim
  • VijaySofist
    New Member
    • Jun 2007
    • 107

    #2
    Hi!

    Can you please Tell me what grid you are using in your program.

    If you mean for a MsFlexGrid, Here is the code

    Code:
    Private Sub Command1_Click()
        DeleteEmptyRows
    End Sub
    Sub DeleteEmptyRows()
        Dim i As Long
        i = 0
        Dim RowDelete As Boolean
        Do While i <= (MSFlexGrid1.Rows - 1)
            RowDelete = DeleteRow(i)
            If RowDelete = True Then
                MSFlexGrid1.RemoveItem (i)
                i = 0
            End If
            i = i + 1
        Loop
    End Sub
    
    Function DeleteRow(rowno As Long) As Boolean
        Dim EmptyRow As Boolean
        Dim i As Long
        i = 0
        EmptyRow = False
        Do While i <= (MSFlexGrid1.Cols - 1)
    
            If ((i = (MSFlexGrid1.Cols - 1)) And (Trim(MSFlexGrid1.TextMatrix(rowno, i)) = "")) Then
                EmptyRow = True
            Else
                If Trim(MSFlexGrid1.TextMatrix(rowno, i)) = "" Then
                    EmptyRow = True
                Else
                    EmptyRow = False
                    Exit Do
                End If
            End If
            i = i + 1
        Loop
        DeleteRow = EmptyRow
    End Function

    Thanks and Regards
    Vijay. R

    Comment

    • ibrahim2008
      New Member
      • Nov 2008
      • 9

      #3
      Thanks Vijay,

      I need this one only.

      Regards,
      Ibrahim

      Comment

      Working...