Results 1 to 3 of 3

Thread: Msflexgrid remove item

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2014
    Posts
    66

    Msflexgrid remove item

    Hello All,

    I'm Using MSFlexgrid. My Doubt was

    HOW TO REMOVE A ROW WHICH ROW'S CAPTION WAS 'HAEMOGLOBIN'(DELETE BY NAME NOT INDEX)

    In the Picture HAEMOGLOBIN Row in first. But that is user's choice.

    Sometimes HAEMOGLOBIN row should be last or middle..

    How can i delete that row...

    Please Help

    Thank you
    Attached Images Attached Images  

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,910

    Re: Msflexgrid remove item

    You could use a For..Next loop to check all rows for the text.
    Something like this [untested]:
    Code:
    Dim lRow As Long
    Dim lRowToDelete As Long
    Dim sSearchText As String
    
    sSearchText = "HAEMOGLOBIN"
    
    With MSFlexGrid1
      For lRow = .FixedRows To .Rows - 1
        If .TextMatrix(lRow, 1) = sSearchText Then
          lRowToDelete = lRow
          Exit For
        End If
      Next lRow
      
      If lRowToDelete >= .FixedRows Then .RemoveItem lRowToDelete
    End With

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,177

    Re: Msflexgrid remove item

    AND (Looks like Arn's code will work for you) just one question. How are you populating your msflexgrid? If it is from a database, please realize that just by removing that row will not delete it from your DB table. You will have to write code to do that.

    Also, Arn's code will find and remove ONE instance of a row with "HAEMOGLOBIN" in column 1, starting at the bottom of the grid, and working upward. If there are more than one row, you'd have to either rerun his code over and over or modify it to delete each found row in the for-loop rather than after it.

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