ravimeetsu Posted December 19, 2002 Posted December 19, 2002 Hi A specific question is that whether I can select a particular row in List View, show the modified row as highlighted and know the row number ?? Regards and Thanks Ravi Hasija Quote
*Experts* Bucky Posted December 20, 2002 *Experts* Posted December 20, 2002 Do you mean you want to select a row with a specific index? If so: MyListView.Items(itemIndex).Selected = True Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
*Experts* Bucky Posted December 20, 2002 *Experts* Posted December 20, 2002 ravimeetsu sent me this PM, so I figured I'd answer it here. Hi Thanks for your concern. I will be more specific this time. I want to modify certain row. My first concern is how to let a user select a row and then how to know which row he selected. For example is it possible for a user to click on a certain row, then I highlight it and then I delete / modify according to my requirement. Please help me with this and feel free to suggest even outside the scope of the question. Regards and Thanks, Ravi Hasija When a row is selected by the user, the SelectedIndexChanged event of the ListView control will fire. In this event, you can get the selected item from the ListView and work with it (where lvw is the name of the ListView control): Private Sub lvw_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lvw.SelectedIndexChanged Dim selectedItem As ListViewItem selectedItem = lvw.SelectedItems(0) ' Do something with selectedItem End Sub If your ListView allows multiple selections by the user, then the other selected items will also be in the SelectedItems collection of the ListView. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
donaldc104 Posted January 17, 2003 Posted January 17, 2003 Index number of selected Item? Good answers in this thread, Bucky. One further question: Is there a way to get the actual Index number of the selected item? (the sequential number in the ListView) ? Quote
*Gurus* divil Posted January 17, 2003 *Gurus* Posted January 17, 2003 selectedItem.Index Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Leeus Posted April 21, 2003 Posted April 21, 2003 Is there any way to get the text contained in that row into a string?? Quote
*Experts* Volte Posted April 21, 2003 *Experts* Posted April 21, 2003 Dim s As String = ListView1.SelectedItems(0).Text Quote
Leeus Posted April 21, 2003 Posted April 21, 2003 Is it possible to get all columns in the row into a string? Sorry I wasn't clear before! Quote
Cassio Posted April 21, 2003 Posted April 21, 2003 Set the listview property FullRowSelect to true. Quote Stream of Consciousness (My blog)
*Experts* Volte Posted April 21, 2003 *Experts* Posted April 21, 2003 You might try something like this:Dim col As ListViewItem.ListViewSubItem Dim ret As String If ListView1.SelectedItems.Count > 0 Then For Each col In ListView1.SelectedItems(0).SubItems ret &= col.Text & "|" Next MessageBox.Show(ret) End If Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.