|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
new to .net can't figure out how to
code a button to move item in a listview to position before current position |
|
#2
|
|||
|
|||
|
Quote:
what do you mean? when you click a button an item in listview will move in another position? is that what you mean? |
|
#3
|
|||
|
|||
|
hmm...
well that's also my problem...
assuming that there's already an items in the listview. when i click the button1, it will transfer to the other position but the problem is it will not remove the original position... i try to put remove method but the item will insert to the first column here the code to listview position to another but w/o removing it... PrivateSub Button1_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Button1.Click Dim str AsString str = ListView1.Items(ListView1.Items.Count - 1).Text ListView1.Items.Add(str) EndSub |
|
#4
|
|||
|
|||
|
I cud not understand neither kelso nor topi clearly..
but here is what I think you need: you want to be able to remove items from listview. Right? I am assuming that you do not have problems adding items to listview but to remove the items. if so, please read thru: There is a property for listview called SelectedItems. listView.SelectedItems will return a collection object of type listView.SelectedListViewItemCollection. You can iterate thru this collection object and delete one (or all) the selected items. I have some code for you below: Code:
Dim selCol As ListView.SelectedListViewItemCollection 'declare a collection object Dim selColItem As ListViewItem 'declare a listview item selCol = Me.ListView1.SelectedItems 'get all the items selected Dim idx As Integer 'index 'iterate thru selected items and delete one after one 'if there is only one selection then ONLY that item 'will be deleted For Each selColItem In selCol Try idx = selColItem.Index 'get index (but not needed) selColItem.Remove() 'delete the selectedItem Catch ex As Exception End Try Next 'after deleting one or more items you can start adding new items does that answer your question(s)? _______________________ Web reading made easy- http://www.xemantex.com |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > listview position control |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|