Function "IndexFromPoint"

2 posts, 0 answers
  1. lupotana
    lupotana avatar
    73 posts
    Member since:
    Nov 2006

    Posted 08 Aug 2008 Link to this post

    Hi,
    in normal Listbox there's a function called IndexFromPointi.
    This function received the position of mouse cursor (X and Y) and return the index of listbox

    This function is not present in RadListBox ?

    Thanks,
    Marco Bianchi
  2. Angel
    Admin
    Angel avatar
    121 posts

    Posted 11 Aug 2008 Link to this post

    Hello Marco,

    Thank you for the suggestion for such an API. Your points have been updated for that.
    Until we add the API, you can use the method given below:

    private int IndexFromPoint(RadListBox listBox, Point pos)  
    {  
        RadItem item = listBox.ElementTree.GetElementAtPoint(pos) as RadItem;  
        if (item != null)  
            return listBox.Items.IndexOf(item);  
        return -1;  

    For example, the code in the handler for MouseMove event of RadListBox will be:

    private void radListBox1_MouseMove(object sender, MouseEventArgs e)  
    {  
        int indexUnderMouse = IndexFromPoint((RadListBox)sender, e.Location);  

    If you have further questions, do not hesitate to write us.

    Greetings,
    Angel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top