Results 1 to 9 of 9

Thread: [RESOLVED] MSFlexGrid Delete All Selected Rows

  1. #1

    Thread Starter
    Registered User
    Join Date
    Apr 2006
    Posts
    62

    Resolved [RESOLVED] MSFlexGrid Delete All Selected Rows

    Hi,

    I would like to know how to delete all the selected rows from an MSFlexGrid contol. What I have now will only delete the last selected row. Anyone know how to do this?

    Thanks!

  2. #2

  3. #3
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Anchorage, Alaska
    Posts
    545

    Re: MSFlexGrid Delete All Selected Rows

    If the code is similar to a Listbox do the following.
    Sorry I don't know anything about MSFlexGrid Control =\

    VB Code:
    1. Private Sub Command2_Click()
    2. Dim Inc As Integer ' or long
    3. For Inc = List1.ListCount - 1 To 0 Step -1
    4.   If List1.Selected = True Then
    5.     List1.RemoveItem
    6.   End If
    7. Next Inc
    8. End Sub
    Please RATE posts, click the RATE button to the left under the Users Name.

    Once your thread has been answered, Please use the Thread Tools and select RESOLVED so everyone knows your question has been answered.


    "As I look past the light, I see the world I wished tonight, never the less, sleep has come, and death shall soon follow..." © 1998 Jeremy J Swartwood

  4. #4

  5. #5
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: MSFlexGrid Delete All Selected Rows

    VB Code:
    1. Private Sub RemoveSelection()
    2.     Dim i As Long, lStartSel As Long, lEndSel As Long
    3.    
    4.     With MSFlexGrid1
    5.         If .RowSel >= .Row Then
    6.             'its a Top -> Down selection
    7.             lStartSel = .Row
    8.             lEndSel = .RowSel
    9.         Else
    10.             'its a Down -> Top selection
    11.             lStartSel = .RowSel
    12.             lEndSel = .Row
    13.         End If
    14.        
    15.         For i = lEndSel To lStartSel Step -1
    16.             .RemoveItem i
    17.         Next
    18.     End With
    19. End Sub
    Last edited by jcis; Jul 27th, 2006 at 11:24 PM.

  6. #6
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Anchorage, Alaska
    Posts
    545

    Re: MSFlexGrid Delete All Selected Rows

    Quote Originally Posted by RhinoBull
    Then you shouldn't reply at all. Sorry.
    Looks like I had the correct idea per post number 4. Just never used it before.

    What is wrong with giving ideas and help? I am not telling him to draw pixels on the screen, or read from a file. I am telling him how to create the correct type of loop. The answer could be ignored, and at the very least, it could trigger a thought in the person who knows more about that type of control.

    I would never post anything anti-productive. I felt it had relevance. I read a lot of posts that I do not post to, because I do not user that contorl, or understand a specific control.
    Please RATE posts, click the RATE button to the left under the Users Name.

    Once your thread has been answered, Please use the Thread Tools and select RESOLVED so everyone knows your question has been answered.


    "As I look past the light, I see the world I wished tonight, never the less, sleep has come, and death shall soon follow..." © 1998 Jeremy J Swartwood

  7. #7

    Thread Starter
    Registered User
    Join Date
    Apr 2006
    Posts
    62

    Re: MSFlexGrid Delete All Selected Rows

    Thanks jcis, it works great!

  8. #8
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: MSFlexGrid Delete All Selected Rows

    Quote Originally Posted by rack
    ...What is wrong with giving ideas and help?...
    Nothing really. The problem however is that vast majority expects presise answers and idea of comparing Listbox with the FlexGrid may (and I'm sure will) create tons of confusion so best way would be not to reply if you aren't sure. Was your idea relevant? Besides the loop it really wasn't.
    That's all.

    Best regards.

  9. #9
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Anchorage, Alaska
    Posts
    545

    Re: [RESOLVED] MSFlexGrid Delete All Selected Rows

    I guess your right =) Sorry, Was in a bad mood yesterday from work, didn't mean to sound rude in my responce =).
    Please RATE posts, click the RATE button to the left under the Users Name.

    Once your thread has been answered, Please use the Thread Tools and select RESOLVED so everyone knows your question has been answered.


    "As I look past the light, I see the world I wished tonight, never the less, sleep has come, and death shall soon follow..." © 1998 Jeremy J Swartwood

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