Results 1 to 9 of 9

Thread: Delete Row in Listview Control

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    174

    Delete Row in Listview Control

    Hello,

    I am in a problem. The problem is that I have got a listview control. The control is populated with some data and the listview's view property is set to report view. What I want is that when I select a row in the listview I want to delete that row. Is it possibl. If yes please give me any idea.

    Thanx in advance.

    Arghya

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Delete Row in Listview Control

    And what initiates the deletion? Button click? Listview double click?

    Code:
    If Not (ListView1.SelectedItem Is Nothing) Then
       ListView1.ListItems.Remove ListView1.SelectedItem.Index
    End If

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Delete Row in Listview Control

    If your listview is being populated from a DB table, then you will need to delete the record from the table as well otherwise, the next time you load your listiview, that row will be back.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    174

    Re: Delete Row in Listview Control

    Thanx to all for the reply and the trouble you have taken to reply to such a silly question. Now can anyone tell me how to change the forecolor and the font style of the last row of the listview control?

    Thanx again

  5. #5
    Addicted Member Ashraf Alshahawy's Avatar
    Join Date
    May 2007
    Location
    Egypt
    Posts
    241

    Re: Delete Row in Listview Control

    ListView1.ListItems(ListView1.ListItems.Count).Bold = True
    ListView1.ListItems(ListView1.ListItems.Count).ForeColor = vbBlue
    Some times when you make a step forward ...You can't get back. Be sure where you make your steps.

  6. #6
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: Delete Row in Listview Control

    vb Code:
    1. Dim i As Long
    2. i = ListView1.ListItems.Count
    3. ListView1.ListItems(i).Bold = True
    4. ListView1.ListItems(i).ForeColor = vbBlue

    He only wants the last row to be changed

  7. #7
    Addicted Member Ashraf Alshahawy's Avatar
    Join Date
    May 2007
    Location
    Egypt
    Posts
    241

    Re: Delete Row in Listview Control

    Short + Efficient = Hell-Lord
    Some times when you make a step forward ...You can't get back. Be sure where you make your steps.

  8. #8
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: Delete Row in Listview Control

    Quote Originally Posted by ashraf fawzy
    Short Code + Efficient = Hell-Lord
    Thanks

  9. #9
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Delete Row in Listview Control

    Just make sure there's actually a listitem in the lisitems collection, otherwise you'll get an error.

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