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.
Printable View
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.
VB Code:
ListView1.ListItems.Add ,"BlankItem", ""
Get a Run time error
VB Code:
ListView1.ListItems.Add
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.
not sure if there's a better way, but try this out:
VB Code:
Private Sub Command1_Click() Dim i As Integer Dim intNewItemPos As Integer Dim itemx As ListItem intNewItemPos = 3 Set itemx = ListView1.ListItems.Add(, , "Bleh10") For i = intNewItemPos To ListView1.ListItems.Count - 1 Set itemx = ListView1.ListItems.Add(, , ListView1.ListItems(intNewItemPos).Text) ListView1.ListItems.Remove (intNewItemPos) Next i End Sub Private Sub Form_Load() Dim itemx As ListItem Set itemx = ListView1.ListItems.Add(, , "Blah1") Set itemx = ListView1.ListItems.Add(, , "Blah2") Set itemx = ListView1.ListItems.Add(, , "Blah3") Set itemx = ListView1.ListItems.Add(, , "Blah4") Set itemx = ListView1.ListItems.Add(, , "Blah5") Set itemx = ListView1.ListItems.Add(, , "Blah6") Set itemx = ListView1.ListItems.Add(, , "Blah7") End Sub
where intNewItemPos is the point you want to insert the new item.
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.
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.
to get the item position, use this:
VB Code:
intNewItemPos = ListView1.SelectedItem.Index
:)
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.