This does the trick:
Dim itm As listviewitem
Dim MaxItems As Integer = lvw.Items.Count - 1 '0-based
Dim Counter As Integer
Do While Counter <= MaxItems
itm = lvw.Items(Counter)
If CInt(itm.Text.Substring(4, 2)) / 2 = CInt(CInt(itm.Text.Substring(4,
2)) / 2) Then 'don't mind my "certain condition
'if certain condition is met then insert new row in the listview
here
'row must be inserted immediately under the current item
lvw.Items.Insert(itm.Index, New ListViewItem("New item"))
Counter += 1
MaxItems += 1
End If
Counter += 1
Loop
Hope this helps,
Stefan
"dotnetnewbie" <do**********@discussions.microsoft.com> wrote in message
news:05**********************************@microsof t.com...
Whilst looping through items in a listview I wish to have the option of
inserting a new row (in the middle not necessarily at the end of the
listview).
thus if lvw is the listview name
dim itm as listviewitem
For each itm in lvw.Items
'if certain condition is met then insert new row in the listview here
'row must be inserted immediately under the current item
next itm
Thanks
Gerry