Click here to Skip to main content
15,920,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want to create a listview, which include in each row a button in the last column. To click on the button starts a handle (VB.NET), that should use the values of the other columns of the same row of the listview. To refer to this values I haves used SelectedItem, but I see this is not correct because the user can click on a button in a row that is not selected. Please what is the right property?
Thanks
Posted
Updated 12-Mar-10 2:06am
v3

Hello,


You surely can get the sender of the event to get the button and use the VisualTreeHelper (http://msdn.microsoft.com/en-us/library/system.windows.media.visualtreehelper.aspx[^]) to get the clicked row.

Hope this helps you !
 
Share this answer
 
Hello,
thank you for your answer. I've tried this:
strText = "Ebene 1 " & VisualTreeHelper.GetParent(sender).ToString & vbCrLf & _
"Ebene 2 " & VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(sender)).ToString & vbCrLf & _
"Ebene 3 " & VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(sender))).ToString & vbCrLf & _
"Ebene 4 " & VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(sender)))).ToString & vbCrLf

and get
Ebene 1 System.Windows.Controls.ContentPresenter
Ebene 2 System.Windows.Controls.GridViewRowPresenter Content:System.Data.DataRowView Columns.Count:7
Ebene 3 System.Windows.Controls.Border
Ebene 4 System.Windows.Controls.ListViewItem: System.Data.DataRowView

What would be the next step, please?

Best greetings
Peter
 
Share this answer
 
Hello,

now I solve the problem with your help:

So the VisualTreeHelper say me, the parent of the parent of my button is a System.Windows.Controls.GridViewRowPresenter I do this:

Dim myGrid As GridViewRowPresenter
Dim LstRow As DataRowView
myGrid = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(sender))
Me.m_PlanRow = CType(myGrid.Content, DataRowView)
strText = LstRow("ANZAHL") & " " & LstRow("ERR_CODE")
...


Thanks
Peter :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900