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

Getting Value Selected By Mouse Click.

2 Answers 109 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Roger
Top achievements
Rank 1
Roger asked on 11 Mar 2021, 09:49 PM

I want to execute some code when a user types and then uses the Mouse to click on an item in the list.  

I will need to access the item selected.

 

I am having a hard time to find the correct event to capture this.

 

Thanks.

2 Answers, 1 is accepted

Sort by
0
Roger
Top achievements
Rank 1
answered on 12 Mar 2021, 02:45 PM

Solution Found.   

https://www.telerik.com/forums/which-event-to-subcribe-when-user-clicks-on-drop-down-list-from-textbox-auto-complete-suggestions

Had to subscribe to:

Register this in the Load or Initialize event

this.racContentTypeOfDoc.ListElement.ElementTree.Control.Click += this.OnListElementClick;

 

Then code this Event.  In my case I was taking the item and putting it in a text box then "Clearing Out" the selected item.

private void OnListElementClick(object sender, EventArgs e)
        {
            ComponentThemableElementTree elementTree = this.racContentTypeOfDoc.ListElement.ElementTree;
            Point mousePosition = elementTree.Control.PointToClient(Control.MousePosition);
            RadElement element = elementTree.GetElementAtPoint(mousePosition);

            while (element != null)
            {
                RadListVisualItem item = element as RadListVisualItem;

                if (item != null)
                {
                    if (txtSearch.Text.Trim().Length > 0)
                        if (rbOr.Checked)
                            txtSearch.Text += " OR (";
                        else
                            txtSearch.Text += " AND (";
                    else
                        txtSearch.Text = "(";
                        txtSearch.Text += item.Text;
                    txtSearch.Text += ")";
                    break;
                }

                element = element.Parent;
            }
            racContentTypeOfDoc.Clear();
        }

 

0
Nadya | Tech Support Engineer
Telerik team
answered on 12 Mar 2021, 03:15 PM

Hello, Roger,

According to the information in your second post, it seems that you managed to found a working solution for your case. I am really glad that handling the ListElement.ElementTree.Control.Click event helps you do the job. 

In case you have any other questions do not hesitate to contact us.

Regards,
Nadya
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
AutoCompleteBox
Asked by
Roger
Top achievements
Rank 1
Answers by
Roger
Top achievements
Rank 1
Nadya | Tech Support Engineer
Telerik team
Share this question
or