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

Show DropDown Popup when focus

6 Answers 501 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Arman
Top achievements
Rank 2
Arman asked on 11 Feb 2014, 05:51 PM
Hi everyone,

I used the below code to show the Dropdown Popup everytime user hits Tab to go to that control. However, now the pop up will disappear if user clicks the little button on the right side of the DropDown control (normal way to show popup), this issue only happens on the first time when the control gets focused. Do you know how to fix this?

Thank you.

Private Sub DropDown_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dpdBodyCondition.Enter
       Dim dpd As RadDropDownList = sender
       If dpd.IsPopupVisible = False Then
           dpd.Popup.Show(dpd)
       End If
   End Sub

6 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 13 Feb 2014, 02:23 PM
Hi Arman,

Thank you for contacting us.

Instead of using the Show method you can programmatically perform click to the drop down list button. This can be done in the GotFocus event of the control for example:
Private Sub radDropDownList1_GotFocus(sender As Object, e As EventArgs)
    radDropDownList1.DropDownListElement.ArrowButton.PerformClick()
End Sub
 
Let me know if you have additional questions.

Regards,
Dimitar
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

0
Arman
Top achievements
Rank 2
answered on 13 Feb 2014, 06:36 PM
Hi Dimitar,

I changed the code as your suggestion. The problem is still there: when you click on the ArrowButton manually, the popup will disappear on the first time the control gets focus. You can test that by moving focus to another control, and then click back to the drop down list ArrowButton.
0
Accepted
Dimitar
Telerik team
answered on 18 Feb 2014, 01:03 PM
Hello Arman,

Thank you for writing back.

Apparently I have missed this exact case. Nevertheless you can avoid this behavior by changing the code like this:
Private Sub radDropDownList1_GotFocus(sender As Object, e As EventArgs)
    Dim element As RadElement = RadDropDownList1.DropDownListElement.ElementTree.GetElementAtPoint(RadDropDownList1.DropDownListElement.PointFromScreen(Control.MousePosition))
    If Not (TypeOf element Is RadDropDownListArrowButtonElement) AndAlso MouseButtons <> System.Windows.Forms.MouseButtons.Left Then
        RadDropDownList1.DropDownListElement.ArrowButton.PerformClick()
    End If
 
End Sub

In this case we will show the drop down manually when the focus is gained, and the button is not clicked.

Do not hesitate to contact us if you have other questions.

Regards,
Dimitar
Telerik
0
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 12 Jun 2020, 05:01 AM

hii Dimitar , can you convert this code into c# ?

 

regards, 

Ras ran

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 12 Jun 2020, 05:29 AM

Hello, Ras Ran,

You can find below the C# code snippet:

        private void radDropDownList1_GotFocus(object sender, EventArgs e)
        {
            RadElement element = this.radDropDownList1.DropDownListElement.ElementTree.GetElementAtPoint(this.radDropDownList1.DropDownListElement.PointFromScreen(Control.MousePosition));
            if (!(element is RadDropDownListArrowButtonElement) && MouseButtons != System.Windows.Forms.MouseButtons.Left)
            {
                this.radDropDownList1.DropDownListElement.ArrowButton.PerformClick();
            }
        }

Feel free to use our free online converter for C# to VB.NET conversion and vice versa: https://converter.telerik.com/

It is quite useful for such cases.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 12 Jun 2020, 11:22 AM

Thank you mr. Dess.....its worked 

regards, 

Ras ran

Tags
DropDownList
Asked by
Arman
Top achievements
Rank 2
Answers by
Dimitar
Telerik team
Arman
Top achievements
Rank 2
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or