This is a migrated thread and some comments may be shown as answers.

Function "IndexFromPoint"

1 Answer 116 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
lupotana
Top achievements
Rank 1
lupotana asked on 08 Aug 2008, 09:54 AM
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

1 Answer, 1 is accepted

Sort by
0
Angel
Telerik team
answered on 11 Aug 2008, 09:27 AM
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.
Tags
General Discussions
Asked by
lupotana
Top achievements
Rank 1
Answers by
Angel
Telerik team
Share this question
or