Search code examples
c#telerik-grid

Reset gridView row selected while paging


I have a pageView with three tabs, each tab has its own radGridView. Below the pageView I have a form displaying some fields not in the gridView. When the page loads the form gets populated with the first value from the first gridView. But when I change tabs I cannot set the focus to the 'new' gridView. Any tips for getting around this?


Solution

  • Try this:

    Private void radPageView_SelectedPageChanged(object sender, EventArgs e)
    {
        if (radPageView1.SelectedPage == radPageView1.Pages["radPageViewPage1"])
        {
            if (this.radGridView1.Rows.Count > 0)
            {
                if (this.radGridView1.Rows.Count == 0)
                {
                    this.radGridView1.Rows[0].IsSelected = true;
                }
    
                this.radGridView2.HideSelection = true;
                this.radGridView2.ClearSelection();
                this.radGridView2.UnSelectAllRows();
                this.radGridView1.Focus();
            }
            else
            {
                _frmEmbededForm.ResetUI(); //ResetUI is my method
            }
        }
        else if (radPageView1.SelectedPage == radPageView1.Pages["radPageViewPage2"])
        {
            if (this.radGridView2.Rows.Count > 0)
            {
                if (this.radGridView2.Rows.Count == 0)
                {
                    this.radGridView2.Rows[0].IsSelected = true;
                }
    
                this.radGridView1.HideSelection = true;
                this.radGridView1.ClearSelection();
                this.radGridView1.UnSelectAllRows();
                this.radGridView2.Focus();
            }
            else
            {
                _frmEmbededForm.ResetUI(); //ResetUI is my method
            }
        }
    }