SearchPanel Focus

2 posts, 0 answers
  1. Kieron
    Kieron avatar
    6 posts
    Member since:
    Jan 2016

    Posted 27 Jul Link to this post

    Hi,

    I've enabled the search panel of a grid, the grid is the only control on a form and I want the initial focus to be in the textbox of the search panel when the user opens the form, how do I go about achieving this?

    Thanks.

     

  2. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    371 posts

    Posted 27 Jul Link to this post

    Hello Kieron,

    The desired behavior can be achieved by handling RadGridView's Loaded event and setting the focus to the TextBox element of the GridViewSearchPanel, like so:

    public MainWindow()
    {
        InitializeComponent();
        this.clubsGrid.Loaded += ClubsGrid_Loaded;
    }
     
    private void ClubsGrid_Loaded(object sender, RoutedEventArgs e)
    {
        var searchPanel = (sender as RadGridView).ChildrenOfType<GridViewSearchPanel>().FirstOrDefault();
        var textBox = searchPanel.ChildrenOfType<TextBox>().FirstOrDefault();
        textBox.Focus();
    }

    Please let me know if such an approach would work for you.

    Regards,
    Dilyan Traykov
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top