i'm new 2 vb.. so there r lots of things i still don understand.
i'm doing a project... i wuld like 2 delete an item which i've added in the listview
wen i click "delete" in e menuitem, it is suppose 2 delete e item i selected..
though the item is remove from e listview, but wen i try 2 add e same data again,
i cant add as the data is already recorded.
so how do i completely remove the item
n how do i delete e item which i select n not others

help needed
James Coleman
i juz wan 2 delete the item which i've selected in e listview.
erm... i hav 2 get the index of the item and each item hav 5 elements.
so i wan 2 make sure that it will b deleted correctly
i've make small changes 2 e codes but it still doesnt work properly,
private sub deleteedit_click(byval sender as system.object, byval e as system.eventargs) handles menuitem8.click
dim index1 as listviewitem.listviewsubitem
dim indexes as listview.selectedindexcollection = _
me.listview1.selectedindices
dim dclass as string
dim dindex as string
dim dname as string
dim dtime "
dim ddate "
for each index in indexes
dclass = me.listview1.items(index).subitems(0).text
dindex = " (1).text
dname = " (2).text
dtime = " (3).text
next
groupbox3.enabled = false
groupbox3.visible = false
me.listview1.items.removeat(index)
dim i as integer
dim n "
dim haha as string
dim hehe "
dim hoho "
dim hihi "
n = listarray.count
dim ecclass as string
dim ecindex "
dim ecname "
dim ectime "
dim ecdate "
dim info "
dim cl "
dim cla "
dim ind "
dim dat "
dim time "
dim na "
dim noof as integer
dim po as string
dim strb as new stringbuilder
dim strb1 as string
dim yes "
dim yes1 "
dim confirm "
dim confirm1 "
dim newrange "
dim j as integer = 0
dim q as integer
dim indx as integer
dim ie as ienumerator = listarray.getenumerator()
n = listarray.count
q = "
ie.reset()
while ie.movenext = true
indx = indx + 1
if j>4 then
strb = stringbuilder
strb1 = nothing
strb.append(dclass & " ")
" (dindex & " ")
" (tdate.Today & " ")
" (dtime & " ")
strb1 = strb.tostring
info = newrange
'''''' class'''''''
cl = info.indexof("~~", 0)
noof = info.length - cl
cla = info.remove(cl, noof)
'''''''index''''''''''''''
haha = info.remove(0, cl + 2).tostring
cl = haha.indexof("~~", 0)
noof = haha.length - cl
ind = haha.remove(cl, noof)
''''''''''date'''''''''''
hehe = haha.remove(0, cl + 2).tostring
cl = hehe.indexof("~~", 0)
noof = hehe.length - cl
cla = hehe.remove(cl, noof)
''''''''time''''''''''
hoho = hehe.remove(0, cl + 2).tostring
cl = hoho.indexof("~~", 0)
noof = hoho.length - cl
cla = hoho.remove(cl, noof)
'''''''''''name''''''''''''''
po = hoho.remove(0, cl + 2).tostring
cl = po.indexof("~~", 0)
noof = po.length - cl
cla = po.remove(cl, noof)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
yes = newrange.trim("~~")
yes1 = yes.indexof(na)
noof = yes.length - yes1
confirm = yes.remove(yes1, noof)
confirm1 = confirm.replace("~~", " ")
if confirm1 = strb1 then
strb.append(na)
strb1 = strb.tostring
ecclass = cla
ecindex = ind
ecname = dat
ectime = time
ecdate = na
q = listarray.count
end if
newrange = nothing
j = 0
end if
newrange & = ctype(ie.current, string) & "~~"
j = j+1
end while
line1:
if j>4 then
strb = stringbuilder
strb1 = nothing
strb.append(dclass & " ")
" (dindex & " ")
" (tdate.Today & " ")
" (dtime & " ")
strb1 = strb.tostring
info = newrange
'''''' class'''''''
cl = info.indexof("~~", 0)
noof = info.length - cl
cla = info.remove(cl, noof)
'''''''index''''''''''''''
haha = info.remove(0, cl + 2).tostring
cl = haha.indexof("~~", 0)
noof = haha.length - cl
ind = haha.remove(cl, noof)
''''''''''date'''''''''''
hehe = haha.remove(0, cl + 2).tostring
cl = hehe.indexof("~~", 0)
noof = hehe.length - cl
cla = hehe.remove(cl, noof)
''''''''time''''''''''
hoho = hehe.remove(0, cl + 2).tostring
cl = hoho.indexof("~~", 0)
noof = hoho.length - cl
cla = hoho.remove(cl, noof)
'''''''''''name''''''''''''''
po = hoho.remove(0, cl + 2).tostring
cl = po.indexof("~~", 0)
noof = po.length - cl
cla = po.remove(cl, noof)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
yes = newrange.trim("~~")
yes1 = yes.indexof(na)
noof = yes.length - yes1
confirm = yes.remove(yes1, noof)
confirm1 = confirm.replace("~~", " ")
if confirm1 = strb1 then
strb.append(na)
strb1 = strb.tostring
ecclass = cla
ecindex = ind
ecname = dat
ectime = time
ecdate = na
q = listarray.count
end if
listarray.remove((indx * 5), 5)
listarray.remove((indx * 5), 5)
end if
j = 0
end if
q = listarray.count
end sub
Eusebiu
Hey,
I don't really understand what you are trying to ask, could you be a little more specific is this a problem with a tool, or something else
Brian
quilty
Hey,
I guess I still really don't understand what this is doing, but doing an Items.Remove should remove it from the listview... I don't understand why it wouldn't remove it...
NickBub
there's nothing wrong wif e tool...
this program is used for pocket pc.
i wan 2 delete a item that i've added into e listview
so wen i click delete, the listview is empty
but wen i try 2 add the same item, cannot b done
coz e data is still recorded inside... its not totally remove
this is my codes:
private sub deleteedit_click(byval sender as system.object, byval e as system.eventargs) handles menuitem8.click
dim index1 as listviewitem.listviewsubitem
dim indexes as listview.selectedindexcollection = _
me.listview1.selectedindices
dim dclass as string
dim dindex as string
dim dname as string
dim dtime "
dim ddate "
for each index in indexes
dclass = me.listview1.items(index).subitems(0).text
dindex = " (1).text
dname = " (2).text
dtime = " (3).text
next
groupbox3.enabled = false
groupbox3.visible = false
me.listview1.items.removeat(index)
dim i as integer
dim n "
dim haha as string
dim hehe "
dim hoho "
dim hihi "
n = listarray.count
dim ecclass as string
dim ecindex "
dim ecname "
dim ectime "
dim ecdate "
dim info "
dim cl "
dim cla "
dim ind "
dim dat "
dim time "
dim na "
dim noof as integer
dim po as string
dim strb as new stringbuilder
dim strb1 as string
dim yes "
dim yes1 "
dim confirm "
dim confirm1 "
dim newrange "
dim j as integer = 0
dim q as integer
dim ie as ienumerator = listarray.getenumerator()
n = listarray.count
q = "
ie.reset()
while ie.movenext = true
if j>4 then
strb = stringbuilder
strb1 = nothing
strb.append(dclass & " ")
" (dindex & " ")
" (tdate.Today & " ")
" (dtime & " ")
strb1 = strb.tostring
info = newrange
'''''' class'''''''
cl = info.indexof("~~", 0)
noof = info.length - cl
cla = info.remove(cl, noof)
'''''''index''''''''''''''
haha = info.remove(0, cl + 2).tostring
cl = haha.indexof("~~", 0)
noof = haha.length - cl
ind = haha.remove(cl, noof)
''''''''''date'''''''''''
hehe = haha.remove(0, cl + 2).tostring
cl = hehe.indexof("~~", 0)
noof = hehe.length - cl
cla = hehe.remove(cl, noof)
''''''''time''''''''''
hoho = hehe.remove(0, cl + 2).tostring
cl = hoho.indexof("~~", 0)
noof = hoho.length - cl
cla = hoho.remove(cl, noof)
'''''''''''name''''''''''''''
po = hoho.remove(0, cl + 2).tostring
cl = po.indexof("~~", 0)
noof = po.length - cl
cla = po.remove(cl, noof)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
yes = newrange.trim("~~")
yes1 = yes.indexof(na)
noof = yes.length - yes1
confirm = yes.remove(yes1, noof)
confirm1 = confirm.replace("~~", " ")
if confirm1 = strb1 then
strb.append(na)
strb1 = strb.tostring
ecclass = cla
ecindex = ind
ecname = dat
ectime = time
ecdate = na
q = listarray.count
end if
newrange = nothing
j = 0
end if
newrange & = ctype(ie.current, string) & "~~"
j = j+1
end while
line1:
if j>4 then
strb = stringbuilder
strb1 = nothing
strb.append(dclass & " ")
" (dindex & " ")
" (tdate.Today & " ")
" (dtime & " ")
strb1 = strb.tostring
info = newrange
'''''' class'''''''
cl = info.indexof("~~", 0)
noof = info.length - cl
cla = info.remove(cl, noof)
'''''''index''''''''''''''
haha = info.remove(0, cl + 2).tostring
cl = haha.indexof("~~", 0)
noof = haha.length - cl
ind = haha.remove(cl, noof)
''''''''''date'''''''''''
hehe = haha.remove(0, cl + 2).tostring
cl = hehe.indexof("~~", 0)
noof = hehe.length - cl
cla = hehe.remove(cl, noof)
''''''''time''''''''''
hoho = hehe.remove(0, cl + 2).tostring
cl = hoho.indexof("~~", 0)
noof = hoho.length - cl
cla = hoho.remove(cl, noof)
'''''''''''name''''''''''''''
po = hoho.remove(0, cl + 2).tostring
cl = po.indexof("~~", 0)
noof = po.length - cl
cla = po.remove(cl, noof)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
yes = newrange.trim("~~")
yes1 = yes.indexof(na)
noof = yes.length - yes1
confirm = yes.remove(yes1, noof)
confirm1 = confirm.replace("~~", " ")
if confirm1 = strb1 then
strb.append(na)
strb1 = strb.tostring
ecclass = cla
ecindex = ind
ecname = dat
ectime = time
ecdate = na
q = listarray.count
end if
listarray.remove(ecclass)
listarray.remove(ecindex)
listarray.remove(ecdate)
listarray.remove(ectime)
listarray.remove(ecname)
arall.remove(ecclass)
arall.remove(ecindex)
arall.remove(ecdate)
arall.remove(ectime)
arall.remove(ecname)
end if
j = 0
end if
q = listarray.count
end sub
how do i delete it completely n it wuld not delete other item in e listview but only e item i choose