Show DropDown Popup when focus

7 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
    2960 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. 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.
  4. Answer
    Dimitar
    Admin
    Dimitar avatar
    2960 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
  5. Ras Ran
    Ras Ran avatar
    140 posts
    Member since:
    Nov 2018

    Posted 12 Jun 2020 in reply to Dimitar Link to this post

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

     

    regards, 

    Ras ran

  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4132 posts

    Posted 12 Jun 2020 Link to this post

    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.
  7. Ras Ran
    Ras Ran avatar
    140 posts
    Member since:
    Nov 2018

    Posted 12 Jun 2020 in reply to Dess | Tech Support Engineer, Sr. Link to this post

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

    regards, 

    Ras ran

Back to Top