Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > ComboBox and ListBox (obsolete as of Q2 2010) > Select an Item in ListBox Control on MouseDown Event

Not answered Select an Item in ListBox Control on MouseDown Event

Feed from this thread
  • Andy avatar

    Posted on Nov 28, 2011 (permalink)

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

    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?

    Reply

  • Ivan Petrov Ivan Petrov admin's avatar

    Posted on Dec 1, 2011 (permalink)

    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.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > ComboBox and ListBox (obsolete as of Q2 2010) > Select an Item in ListBox Control on MouseDown Event
Related resources for "Select an Item in ListBox Control on MouseDown Event"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]