Results 1 to 2 of 2

Thread: MSFLEXGRID - Delete Rows with Mescled columns

  1. #1

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Question MSFLEXGRID - Delete Rows with Mescled columns

    I want to delete some rows from FLEXGRID , with MERGE some rows , (see figure )

    I tried with routine below, but do not work


    What is wrong ?


    Code:
    Private Sub Deleta_Servicos()
      Dim LngStartRow As Long
      Dim lngEndRow As Long
      Dim icont As Long
    
        With Me.MSFlexGrid1
            .ReDraw = False
            lngEndRow = Me.MSFlexGrid1.Row
            Do
                If lngEndRow = .Rows - 1 Then Exit Do
                If .TextMatrix(lngEndRow + 1, 0) = "" Then Exit Do
                lngEndRow = lngEndRow + 1
        
            Loop
        
            LngStartRow = .Row
            Do
                If LngStartRow = .FixedRows Then Exit Do
                If .TextMatrix(LngStartRow - 1, 0) = "" Then Exit Do
                LngStartRow = LngStartRow - 1
            Loop
            For icont = LngStartRow To lngEndRow + 1
              MSFlexGrid1.RemoveItem icont
            
            Next
             .ReDraw = True
        End With
     
    End Sub


    Thanks
    Last edited by mutley; May 13th, 2006 at 10:45 AM. Reason: Put figuere

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: MSFLEXGRID - Delete Rows with Mescled columns

    When using RemoveItem either loop in reverse order or always delete the same row

    VB Code:
    1. For icont = lngEndRow to LngStartRow Step -1
    2.     MSFlexGrid1.RemoveItem icont
    3. Next
    4. Or
    5. For icont = LngStartRow to lngEndRow
    6.     MSFlexGrid1.RemoveItem LngStartRow
    7. Next

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width