how to change font style of a textbox using reportviewer

1 Answer 117 Views
Report Viewer - WinForms
Alessandro
Top achievements
Rank 1
Iron
Alessandro asked on 10 Nov 2022, 09:43 AM

i'm following this example: https://docs.telerik.com/reporting/embedding-reports/program-the-report-definition/access-report-items-programmatically

when it comes to this:

protected void Button1_Click(object sender, EventArgs e)
{
    Telerik.Reporting.InstanceReportSource instanceReportSource = (Telerik.Reporting.InstanceReportSource)this.reportViewer1.ReportSource;
    Telerik.Reporting.Report report = (Telerik.Reporting.Report)instanceReportSource.ReportDocument;
    Telerik.Reporting.TextBox txt = report.Items.Find("productNameDataTextBox", true)[0] as Telerik.Reporting.TextBox;
}

but in my situation I have a UriReportSource,
how can i get InstanceReportSource from a UriReportSource?

 

 

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 14 Nov 2022, 04:20 PM

Hi Alessandro,

Thank you for the provided information!

In order to modify a TRDP/TRDX report through code, you need to create Telerik.Reporting.Report object from the file bytes which can happen by unpackaging the report if it is a TRDP report, or deserializing it if it is a TRDX report.

Once you have the Report object, you may edit it and after you have finished with the edits, you need to wrap it in an InstanceReportSource before setting it as ReportSource of the report viewer.

For example:

Telerik.Report.Report report;
var reportPackager = new ReportPackager();
using (var sourceStream = System.IO.File.OpenRead("Report1.trdp")) 
//can also get the report Uri from the ReportViewer.ReportSource by casting it to UriReportSource 
{
    report = (Report)reportPackager.UnpackageDocument(sourceStream);
}

// report editing

var irs = new InstanceReportSource() { ReportDocument = report };
this.reportViewer1.ReportSource = irs;
this.reportViewer1.RefreshReport();

Please let me know if you have any further questions or if you need further assistance.

Regards,
Dimitar
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
Tags
Report Viewer - WinForms
Asked by
Alessandro
Top achievements
Rank 1
Iron
Answers by
Dimitar
Telerik team
Share this question
or