Select an Item in ListBox Control on MouseDown Event

2 posts, 0 answers
  1. Andy
    Andy avatar
    1 posts
    Member since:
    Oct 2011

    Posted 28 Nov 2011 Link to this post

    When using the standard listbox control i use the IndexFromPoint Method to get the item at the point of the mouse click...

    private void listBox1_MouseDown(object sender, MouseEventArgs e)
        int index = listBox1.IndexFromPoint(e.Location);
        listBox1.SelectedIndex = index;
    is a there a way to do such with a RadListControl?
  2. Ivan Petrov
    Ivan Petrov avatar
    701 posts

    Posted 01 Dec 2011 Link to this post

    Hello Andy,

    Thank you for writing and for the provided code snippet.

    To achieve the same functionality using the RadListControl, you should use the following code:

    private void radListControl1_MouseDown(object sender, MouseEventArgs e)
      RadElement element = this.radListControl1.ElementTree.GetElementAtPoint(e.Location);
      if (!(element is RadListVisualItem))
        element = element.FindAncestor<RadListVisualItem>();
      if (element != null)
        RadListDataItem item = ((RadListVisualItem)element).Data;
        this.radListControl1.SelectedItem = item;

    I hope you will find this useful. Please note that we are still expecting an answer from your on the questions asked in your thread: "unable to clear multiple selected dates". This will allow us to continue supporting your enquiries.

    Best wishes,
    Ivan Petrov
    the Telerik team

    Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

  3. DevCraft R3 2016 release webinar banner
Back to Top