Show DropDown Popup when focus

4 posts, 1 answers
  1. Arman
    Arman avatar
    2 posts
    Member since:
    Oct 2012

    Posted 11 Feb 2014 Link to this post

    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
  2. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 13 Feb 2014 Link to this post

    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).

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Arman
    Arman avatar
    2 posts
    Member since:
    Oct 2012

    Posted 13 Feb 2014 Link to this post

    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.
  5. Answer
    Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 18 Feb 2014 Link to this post

    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
Back to Top