How to get the items with ListView control selected?
-
1 мая 2012 г. 17:30
I want to add a tooltip for items of Listview. I use the code below.
Private Sub ListViewProjectsList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListViewProjectsList.SelectedIndexChanged
If ListViewProjectsList.SelectedItems.Count = 0 Then
MsgBox("No Items is seledted at all")
End If
ToolTip1.SetToolTip(ListViewProjectsList, ListViewProjectsList.SelectedItems(0).Text)End Sub
I click one of the item within my listview control. I think I have already selected it.
It enter into sub ListViewProjectsList_SelectedIndexChanged(). However it pop up a box say "No Items is seledted at all".
Why? How can I get the item selected.Thanks in advance.
Все ответы
-
1 мая 2012 г. 17:45
If you click an item that is already selected, then that item will be cleared and the SelectedIndexChanged event will still fire (with no items selected).
Maybe you could explain more what you are trying to do.
Paul ~~~~ Microsoft MVP (Visual Basic)
-
1 мая 2012 г. 18:02
Thank you. Paul.
Every time, I select different item within that Listview Control. It also pops up the box saying "No Items is seledted at all".
What I trying to do is below.
I want to add a tooltip for the "item" of Listview, not for the ListView control itself. The latter is easy. However, for the former, the item appears only at run time. How to do it? Thank you!
This time, is it clear?
- Изменено hyeewang 1 мая 2012 г. 18:06
-
2 мая 2012 г. 12:28
You can set the ToolTipText property of the ListView item before adding it to the ListView:
http://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.tooltiptext.aspx
Paul ~~~~ Microsoft MVP (Visual Basic)
- Предложено в качестве ответа Shanks ZenMicrosoft Contingent Staff, Moderator 9 мая 2012 г. 9:35
- Помечено в качестве ответа Shanks ZenMicrosoft Contingent Staff, Moderator 9 мая 2012 г. 9:35
-
13 мая 2012 г. 4:40
Thank you. Paul.

