-
October 12th, 2018, 10:52 PM
#1
ListView column reference
Hi, I just put a ListView control on a Windows Form, and have set it to have two columns. I'm trying to build a method that uses the selected item of the ListView to find info in the database. The problem I'm having is finding out how to refer to the item that is in the second column of the selected row of the ListView. Here's the line I'm working with:
Code:
str = "SELECT Nickname, Base, Target, Pause FROM Backup WHERE Nickname = " & "'" & LstVwPlanBackup.SelectedItems.ToString() & "'"
So the selected item is an object, and not a single value. But what I need is the second column value of that ListView. Does anyone know how I refer to that subitem to get the value?
-
October 13th, 2018, 10:23 PM
#2
Re: ListView column reference
Well, for those that may be looking at this thread I have found the answer to my question:
Code:
LstVwPlanBackup.FocusedItem.Index
That refers the index of the selected item in the ListView.
It has brought up a second problem, however. The following code renders an unusable string value as "ListViewSubItem: {Check3}", when all I want is the item value of "Check3".
Code:
LstVwPlanBackup.FocusedItem.SubItems(1).ToString()
Does anyone know how I can get the individual value of the subitem?
-
October 13th, 2018, 11:00 PM
#3
Re: ListView column reference
Found out the answer to that question as well:
Code:
LstVwPlanBackup.Items(LstVwPlanBackup.FocusedItem.Index).SubItems(1).Text.ToString()
The "Text" property or member is the difference. It returns the text value of the subitem in that index.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|