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

Visual Indication of Focus

14 Answers 189 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 12 Jan 2011, 07:57 PM
Is there any way to show that a RadDropDownList has the focus?

14 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 12 Jan 2011, 09:16 PM
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
0
Richard
Top achievements
Rank 1
answered on 12 Jan 2011, 09:31 PM
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?
0
Richard Slade
Top achievements
Rank 2
answered on 12 Jan 2011, 10:04 PM
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
0
Stefan
Telerik team
answered on 14 Jan 2011, 12:21 PM
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.
0
Howard Hill
Top achievements
Rank 1
answered on 02 Aug 2011, 11:32 PM
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.
0
Stefan
Telerik team
answered on 04 Aug 2011, 04:16 PM
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 >>

0
Howard Hill
Top achievements
Rank 1
answered on 04 Aug 2011, 07:47 PM
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.
0
Stefan
Telerik team
answered on 09 Aug 2011, 04:32 PM
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 >>

0
Josue
Top achievements
Rank 1
answered on 03 Nov 2011, 07:09 AM
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?


0
Stefan
Telerik team
answered on 07 Nov 2011, 12:23 PM
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.

0
Kim
Top achievements
Rank 1
answered on 30 Oct 2013, 05:48 PM

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
0
Stefan
Telerik team
answered on 01 Nov 2013, 07:16 AM
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 >>
0
Niloofar
Top achievements
Rank 1
answered on 25 Mar 2015, 03:21 PM
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 
0
Stefan
Telerik team
answered on 30 Mar 2015, 10:45 AM
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.

 
Tags
DropDownList
Asked by
Richard
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Richard
Top achievements
Rank 1
Stefan
Telerik team
Howard Hill
Top achievements
Rank 1
Josue
Top achievements
Rank 1
Kim
Top achievements
Rank 1
Niloofar
Top achievements
Rank 1
Share this question
or