New to Telerik UI for WinFormsStart a free 30-day trial

Prevent the control from gaining focus

Updated over 1 year ago

Currently, RadCommandBar receives the focus. One can easily override this behavior and do not allow the control to become focused. Here are the three simple steps that need to be followed:

  1. Create a custom class that derives from RadCommandBar;

  2. Override the ThemeClassName property, so that the theming mechanism can recognize the new control as a RadCommandBar;

  3. Override the ProcessFocusRequested method and return false.

C#
class MyCommandBar : RadCommandBar
{
    public override string ThemeClassName
    {
        get
        {
            return typeof(RadCommandBar).FullName;
        }
    }
    protected override bool ProcessFocusRequested(RadElement element)
    {
        return false;
    }
}
Not finding the help you need?
Contact Support