Results 1 to 10 of 10

Thread: Listview Insert/Remove

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2000
    Posts
    462

    Listview Insert/Remove

    What it the call to insert a blank line in a Listview.

    Is it add or what

    I think Listview.Remove K will take out a line where you want.
    Don
    (OLD DOS Programmer)

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    VB Code:
    1. ListView1.ListItems.Add ,"BlankItem", ""
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2000
    Posts
    462

    Error

    Get a Run time error
    Don
    (OLD DOS Programmer)

  4. #4
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    VB Code:
    1. ListView1.ListItems.Add

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2000
    Posts
    462

    List view

    That will not add a line to listview

    What I would like to do is select the spot where I wish to add a line.

    Been looking and found nothing.

    In Dos it would look something like THis
    Where Eform is form name
    Inkey_Text(1) is the editor for lables I use
    Inkey(Line_num)=is the Label where the Info is Displayed
    Pages(x,x) it the data array

    Sub Do_AltI() ' Insert A Line
    Eform.Inkey_Text(1).Text = Space$(Len(Inkey(Line_Num)))
    XX = 24
    Do Until XX = Row
    Page_s(XX, 1) = Page_s((XX - 1), 1)
    Page_s(XX, 2) = Page_s((XX - 1), 2)
    Paged(XX, 1) = Paged((XX - 1), 1)
    Paged(XX, 2) = Paged((XX - 1), 2)
    Paged(XX, 3) = Paged((XX - 1), 3)
    Paged(XX, 4) = Paged((XX - 1), 4)
    XX = XX - 1
    Loop
    Page_s(Row, 1) = 0
    Page_s(Row, 2) = 0
    Paged(Row, 1) = ""
    Paged(Row, 2) = ""
    Paged(Row, 3) = ""
    Paged(Row, 4) = ""
    Txs(Row) = 0
    Stc(Row) = 0
    Reprint
    End Sub

    Now I could do this to the information in the listview but i know there must be a better way.
    Last edited by Dbee; Oct 7th, 2002 at 07:11 AM.
    Don
    (OLD DOS Programmer)

  6. #6
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638
    not sure if there's a better way, but try this out:

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim i As Integer
    3.     Dim intNewItemPos As Integer
    4.     Dim itemx As ListItem
    5.    
    6.     intNewItemPos = 3
    7.    
    8.     Set itemx = ListView1.ListItems.Add(, , "Bleh10")
    9.    
    10.     For i = intNewItemPos To ListView1.ListItems.Count - 1
    11.         Set itemx = ListView1.ListItems.Add(, , ListView1.ListItems(intNewItemPos).Text)
    12.         ListView1.ListItems.Remove (intNewItemPos)
    13.     Next i
    14. End Sub
    15.  
    16. Private Sub Form_Load()
    17.     Dim itemx As ListItem
    18.    
    19.     Set itemx = ListView1.ListItems.Add(, , "Blah1")
    20.     Set itemx = ListView1.ListItems.Add(, , "Blah2")
    21.     Set itemx = ListView1.ListItems.Add(, , "Blah3")
    22.     Set itemx = ListView1.ListItems.Add(, , "Blah4")
    23.     Set itemx = ListView1.ListItems.Add(, , "Blah5")
    24.     Set itemx = ListView1.ListItems.Add(, , "Blah6")
    25.     Set itemx = ListView1.ListItems.Add(, , "Blah7")
    26. End Sub

    where intNewItemPos is the point you want to insert the new item.
    Last edited by tr0n; Oct 7th, 2002 at 07:07 AM.

  7. #7
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638
    did i misunderstand you? do you want to insert a new listitem at a certain position rather than at the bottom? that's what my code will do. otherwise, i don't understand what you want.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2000
    Posts
    462

    listview

    I tryed you code its fine, but to determain the postion of the insert is a pain.

    Yes that is what i am trying to do. The dos routine take the data and does a insert or delete. Then you have to repost it to the screen.
    Don
    (OLD DOS Programmer)

  9. #9
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638
    to get the item position, use this:

    VB Code:
    1. intNewItemPos = ListView1.SelectedItem.Index


  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2000
    Posts
    462

    List view

    Prior to me trying to do listview

    I had to create a form with say 8 columns and 24 items
    by placeing 192 Labels on the form. and then using the array placing data in the form that way.

    Like I said it was the old DOS way of doing things.

    Conversion to VB is a learing experince for an old fart.
    Don
    (OLD DOS Programmer)

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