Hello Mohammad,
You're correct. If you're going to have hit targets that are not the ListViewItem, then you can climb the element tree until you get to the BaseListViewVisualItem.
For example, you can use the approach where you check the type first, if it is not the type you want, then climb the element tree until you find the right type:
That will work even if you right click on a button.
Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
You're correct. If you're going to have hit targets that are not the ListViewItem, then you can climb the element tree until you get to the BaseListViewVisualItem.
For example, you can use the approach where you check the type first, if it is not the type you want, then climb the element tree until you find the right type:
// Just accept whatever type it is first
var clickedItem = radListView1.ElementTree.GetElementAtPoint(e.Location);
// Check it's type, if it's not then climb the tree until you find the base
var visualItem = clickedItem
as
BaseListViewVisualItem ?? clickedItem.FindAncestor<BaseListViewVisualItem>();
// Just a little extra defensive programming
if
(visualItem ==
null
)
return
;
That will work even if you right click on a button.
Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.