By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,706 Members | 2,030 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,706 IT Pros & Developers. It's quick & easy.

Select a ListViewItem from outside

P: n/a
Hey folks,

I have a problem with selecting an item in a listview control from outside.

Listview items are binded with unique ids.
I got now an id from another control and want to select the specific
listview-item. Is there a chance I haven't seen jet?

Thanks for you help
Joerg
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Maybe I have to explain it more detailed:

I have a windows form looks like the windows explorer with an treeview,
listview and an imageviewer containing layers where markers for the filterd
listview items are painted. With the key of the selected listview item I can
highlight the marker of the imageviewer control. With the key of the
selected marker in the imageviewer control I want to select the specific
listview item. How does this work?
Almost all properties of the listview control are read only.
Does this work with getitemat(x,y) and how?

Would be so awesome if someone knows a way.

Joerg

"Joerg Trumpfheller" <NO****@spearhead-home.com> schrieb im Newsbeitrag
news:cr*********@doiweb4.b2x.vwg...
Hey folks,

I have a problem with selecting an item in a listview control from outside.
Listview items are binded with unique ids.
I got now an id from another control and want to select the specific
listview-item. Is there a chance I haven't seen jet?

Thanks for you help
Joerg

Nov 21 '05 #2

P: n/a
Maybe I have to explain it more detailed:

I have a windows form looks like the windows explorer with an treeview,
listview and an imageviewer containing layers where markers for the filterd
listview items are painted. With the key of the selected listview item I can
highlight the marker of the imageviewer control. With the key of the
selected marker in the imageviewer control I want to select the specific
listview item. How does this work?
Almost all properties of the listview control are read only.
Does this work with getitemat(x,y) and how?

Would be so awesome if someone knows a way.

Joerg

"Joerg Trumpfheller" <NO****@spearhead-home.com> schrieb im Newsbeitrag
news:cr*********@doiweb4.b2x.vwg...
Hey folks,

I have a problem with selecting an item in a listview control from outside.
Listview items are binded with unique ids.
I got now an id from another control and want to select the specific
listview-item. Is there a chance I haven't seen jet?

Thanks for you help
Joerg

Nov 21 '05 #3

P: n/a
For those who are interrested - here is a solution

Private Sub ImageViewer_SelectHandler(Byval SearchID as long) Handles
RaiseEventfrom.MarkerSelected

Try

Dim selItems As New ListView.ListViewItemCollection(ListView1)

Dim lviProps As ListViewItemProps

Dim i As ListViewItem

For Each i In selItems

Dim ind As Integer = i.Index

' Parse the Tag

lviProps = CType(i.Tag, ListViewItemProps)

If (CLng(lviProps.ItemKey) = SearchID) Then

Debug.WriteLine("Found: " & CLng(lviProps.ItemKey) & " - " & SearchID)

selItems(ind).Selected = True

Else

selItems(ind).Selected = False

End If

Debug.WriteLine(CLng(lviProps.ItemKey) & " - " & SearchID)

Next i

Catch ex As Exception

Throw New Exception(Me.ToString & ".ImageViewer_SelectHandler: " &
ex.ToString & vbCrLf)

End Try

end sub

Public Structure ListViewItemProps

Dim ItemKey As Object

....

End Structure

Joerg
Nov 21 '05 #4

P: n/a
For those who are interrested - here is a solution

Private Sub ImageViewer_SelectHandler(Byval SearchID as long) Handles
RaiseEventfrom.MarkerSelected

Try

Dim selItems As New ListView.ListViewItemCollection(ListView1)

Dim lviProps As ListViewItemProps

Dim i As ListViewItem

For Each i In selItems

Dim ind As Integer = i.Index

' Parse the Tag

lviProps = CType(i.Tag, ListViewItemProps)

If (CLng(lviProps.ItemKey) = SearchID) Then

Debug.WriteLine("Found: " & CLng(lviProps.ItemKey) & " - " & SearchID)

selItems(ind).Selected = True

Else

selItems(ind).Selected = False

End If

Debug.WriteLine(CLng(lviProps.ItemKey) & " - " & SearchID)

Next i

Catch ex As Exception

Throw New Exception(Me.ToString & ".ImageViewer_SelectHandler: " &
ex.ToString & vbCrLf)

End Try

end sub

Public Structure ListViewItemProps

Dim ItemKey As Object

....

End Structure

Joerg
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.