Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 78072

How to get index of ListView item on right click

$
0
0
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:

// 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.

Viewing all articles
Browse latest Browse all 78072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>