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

Lose focus on active control when calling RefreshReport() method for ReportViewer

2 Answers 108 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Danilo
Top achievements
Rank 1
Danilo asked on 22 Jan 2015, 10:25 AM
Hello everyone

In my application I have a Telerik.Reporting.ReportViewer to load a preview of a report. I also have many controls like RadTextBox or RadDropDownList etc. What I'm trying to do is when the user changes the text of a RadTextBox it should reload the ReportViewer. To do this I'm using RefreshReport() method. But when I call this method it loses the focus on the textbox. I already tried refocus the control after calling the RefreshReport() method but this didn't work neither. I found this thread of October 2009:

http://www.telerik.com/forums/winforms-report-viewer-quot-refreshreport-quot-sets-focus

I'm wondering now, 5 years later, if there is a way to prevent losing focus on the control when calling RefreshReport() method?

Ah, if you want to have a look at my code, here it is:

InstanceReportSource report = new InstanceReportSource();
reportSpedi.ReportSource = new Spediauftrag(this);
reportSpedi.RefreshReport();

// active textbox
txtSpediGewicht.Select();

Regards,
Danilo

2 Answers, 1 is accepted

Sort by
0
Accepted
Stef
Telerik team
answered on 26 Jan 2015, 01:39 PM
Hi Danilo,

On refreshing the report the focus will be taken from the external UI, but you can use the exposed WinForms ReportViewer API to set back the focus to the desired control OnUpdateUI:

public Form1()
{
    InitializeComponent();
    reportViewer1.UpdateUI += reportViewer1_UpdateUI;
    reportViewer1.ReportSource = new InstanceReportSource { ReportDocument = new Report1() };
    reportViewer1.RefreshReport();
}
 
void reportViewer1_UpdateUI(object sender, EventArgs e)
{
    textBox1.Select();
}


Let us know if you need any further help.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Danilo
Top achievements
Rank 1
answered on 02 Feb 2015, 08:13 AM
Hi Stef,

Thank you very much, it's working fine now.

Regards,
Danilo
Tags
General Discussions
Asked by
Danilo
Top achievements
Rank 1
Answers by
Stef
Telerik team
Danilo
Top achievements
Rank 1
Share this question
or