473,411 Members | 2,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Select a ListViewItem from outside

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
4 3178
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Islam Elkhayat | last post by:
In my Application i search my Employee database and view result in List View with 3 column.. here is the code: ######################################### private void textBox1_TextChanged(object...
1
by: Giang Pham | last post by:
Dear all, When I add one row in my listview (type : details), I want to set it as selected. How could I do this ? Thank you a lot.
6
by: grs | last post by:
The following is a code example from the Microsoft MSDN. My question is on the following three lines of code: ListViewItem item1 = new ListViewItem("item1",0); ListViewItem item2 = new...
4
by: M K | last post by:
Using VS 2005 I have a listview that displays: number, name, details (in that order) when the user selects a row (single select) i want to retrieve each column in a variable. number is...
2
by: Kela | last post by:
An interesting problem: I have a ListView with LabelEdit set to TRUE. When I change the label, I want to make some decisions as to whether the ListViewItem (that's just been edited) should stay in...
0
by: garyusenet | last post by:
I am trying to create a form that will display a list of open internet explorer windows and allow the user to choose one of them. So far I have created an arraylist which contains all of the open...
3
by: Steve Richter | last post by:
when enumerating thru the properties of a type, how do I select only the properties of the derived class? In the example below, the AddrBookPrompt class is derived from the Form class. When I...
13
by: deciacco | last post by:
How can I have access to the items collection of a listview control on my form from a background thread? I know I need delegates to update the listview control and I have those calls in the...
10
by: Gav | last post by:
I am trying to have a ListView to dispay a list of names and want to have an id stored within the list but not visable. I have tried to go about doing this by using the ListViewItem and setting...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.