Visual Indication of Focus

15 posts, 0 answers
  1. Richard
    Richard avatar
    23 posts
    Member since:
    Jun 2009

    Posted 12 Jan 2011 Link to this post

    Is there any way to show that a RadDropDownList has the focus?
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 12 Jan 2011 Link to this post

    Hello Richard,

    As far as I'm aware, the RadDropDownList does not support AllowShowFocusCues like the RadButton and some other RadControls do. If however you have the RadDropDownList set to
    this.radDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown;
    rather than
    this.radDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
    then you can see when it is focused as the textboxitems text becomes highlighted.

    Hope that helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Richard
    Richard avatar
    23 posts
    Member since:
    Jun 2009

    Posted 12 Jan 2011 Link to this post

    But this allows the users to enter text into what is supposed to be a choice box.

    Since users can tab to RadDropDownList controls, shouldn't the control show the focus?
  5. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 12 Jan 2011 Link to this post

    Hello

    Yes, the DropDown style allows a user to type. The DropDownList style does not. There are no other visual focus elements that can be set however.
    Regards,
    Richard
  6. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 14 Jan 2011 Link to this post

    Hi Richard Sargent,

    Thank you for writing.

    When DropDownStyle is set to DropDownList and if you enable the AllowShowFocusCues property, you will see the focus cues as in the case of RadButton for example.

    When DropDownStyle is set to DropDown, then the text becomes highlighted which is the indicator that the control is on focus.

    A third option is to make your own indicator, for example, a border which changes its colors. This can be achieved by subscribing to the GotFocus and LostFocus events of RadDropDownList. Please refer to the following code snippet, where you can observe such a functionality:

    private Color initialColor;
    protected override void OnShown(EventArgs e)
    {
        base.OnShown(e);
        initialColor = ((BorderPrimitive)radDropDownList1.DropDownListElement.Children[2]).ForeColor;
    }
     
    void radDropDownList1_LostFocus(object sender, EventArgs e)
    {
        ((BorderPrimitive)radDropDownList1.DropDownListElement.Children[2]).ForeColor = initialColor;
    }
     
    void radDropDownList1_GotFocus(object sender, EventArgs e)
    {
        ((BorderPrimitive)radDropDownList1.DropDownListElement.Children[2]).ForeColor = Color.Yellow;
    }

    I hope you find this information helpful. Let me know if you need anything else.

    Richard, thank you for the community effort.

    Best wishes,
    Stefan
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  7. Howard Hill
    Howard Hill avatar
    4 posts
    Member since:
    Apr 2010

    Posted 02 Aug 2011 Link to this post

    I just tried the AllowShowFocusCues on a DropDownList but when I tab into the field nothing changes. If I do the same thing with the RadButton on the same form I get the dashed line cue. Is there something else that needs to be set for AllowShowFocusCues to work?

    I am using Q2 10 controls currently if that matters.
  8. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 04 Aug 2011 Link to this post

    Hi Howard.

    Thank you for writing.

    As I have mentioned in my previous reply, AllowShowFocusCues will work only if the DropDownStyle of RadDropDownList is set to DropDownList.

    I hope this helps.
     
    Kind regards,
    Stefan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  9. Howard Hill
    Howard Hill avatar
    4 posts
    Member since:
    Apr 2010

    Posted 04 Aug 2011 Link to this post

    Yes it does help. What I thought was a DropDownList turned out to be a combo box. Still having the same problem with the combo box but I will post something in that forum.

    Sorry for the confusion.
  10. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 09 Aug 2011 Link to this post

    Hello Howard,

    Please find the answer in the other forum thread which you have opened. 

    Greetings,
    Stefan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  11. Josue
    Josue avatar
    3 posts
    Member since:
    Nov 2011

    Posted 03 Nov 2011 Link to this post

    Hi Stefan,

    The option to set the border color is great to highlight the DropDownList

    I have a doubt about the override OnShow:
    protected override void OnShown(EventArgs e)
    {
    base.OnShown(e);
    initialColor = ((BorderPrimitive)radDropDownList1.DropDownListElement.Children[2]).ForeColor;
    }

    from what class is overriding ?

    also the line

    initialColor = ((BorderPrimitive)radDropDownList1.DropDownListElement.Children[2]).ForeColor;

    is not getting the proper initial border color, maybe because the theme?


  12. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 07 Nov 2011 Link to this post

    Hi Josue,

    Thank you for writing.

    The override of the OnShown is override of the OnShown event of the Form, which I am using to pick up the default control color. However, further tests proved that the GotFocus event of RadDropDownList is fired before the OnShown event of the form and this is why the initialColor variable has incorrect value. 

    Please move the code from the OnShown event of the Form to the OnLoad event, where you should be able to pick up the default border color of RadDropDownList:
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        initialColor = ((BorderPrimitive)radDropDownList1.DropDownListElement.Children[2]).ForeColor;
    }

    I hope that the provided information addresses your question. Should you have any other questions, do not hesitate to contact us.
     
    Best wishes,
    Stefan
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  13. Kim
    Kim avatar
    47 posts
    Member since:
    Jul 2013

    Posted 30 Oct 2013 Link to this post


    Hi,

    I have a control which inherits  RadDropDownList.

    Where would i put the code to check and store the initial border color? In the class constructor?

    Also, when i inspected the DropDownList (this.DropDownListElement.Children), the element at index 0 was the BorderPrimitive, not 2 like in your example. Why the difference?

    Thanks,

    Kim
  14. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 01 Nov 2013 Link to this post

    Hello KIm,

    Please allow me to suggest a better solution, namely to just reset the color of the border instead of saving its initial value. This can be done with the ResetValue method. Here is how your control should look like:
    class MyDropDownList : RadDropDownList
    {
        protected override void OnGotFocus(EventArgs e)
        {
            base.OnGotFocus(e);
            ((BorderPrimitive)this.DropDownListElement.Children[0]).ForeColor = Color.Yellow;
        }
     
        protected override void OnLostFocus(EventArgs e)
        {
            base.OnLostFocus(e);
            ((BorderPrimitive)this.DropDownListElement.Children[0]).ResetValue(BorderPrimitive.ForeColorProperty, ValueResetFlags.Local);
        }
     
        public override string ThemeClassName
        {
            get
            {
                return typeof(RadDropDownList).FullName;
            }
        }
    }

    As to the question about the index, the control element tree has been changed hence the difference in the indexes. Such modifications are always announced in our Release notes section. Here is the announcement for this change: http://www.telerik.com/products/winforms/whats-new/release-history/q3-2012-version-2012-3-1017.aspx.

    I hope this helps.

    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  15. Niloofar
    Niloofar  avatar
    24 posts
    Member since:
    Jan 2015

    Posted 25 Mar 2015 Link to this post

    Hi, I am wondering if there is anyway to change the focus color for whole grid cells or is there any property for setting tableelement focus color?
    thanks 
  16. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 30 Mar 2015 Link to this post

    Hi Niloofar,

    May I please ask you to open a new thread with your question, in the grid section, as it is completely unrelated to the initial subject of this thread.

    Thank you for the understanding. We are trying to keep our forums clean and easy to search.

    Regards,
    Stefan
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready