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

How to get Data from Winforms TextBoxes at Runtime

2 Answers 82 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 17 Jan 2012, 08:40 AM
Hi, am new to telerik and programing in general, i need help in understanding how i can obtain fields from a datareader or text box in winforms and have the telerik report that i built as a class libraray access the data or the text at runtime. My problem is because they are built as seperate parts, i cant seem to figure out how to refer the result runtime data or text to appear in the the report, any help will be greatly appreciated

2 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 20 Jan 2012, 09:32 AM
Hello Daniel,

Once you prepare your report definition and add reference to the reports' class library. You can access the report definition and set up an ObjectDataSource Component. Any of the following data sources can be assigned to the DataSource property of the ObjectDataSource component:


Check out the following code snippet:
public MainForm()
{
    InitializeComponent();
    var report = new ReportCatalog();
 
    // Creating and configuring the ObjectDataSource component:
    Telerik.Reporting.ObjectDataSource objectDataSource = new Telerik.Reporting.ObjectDataSource();
    objectDataSource.DataSource = typeof(Products); // Specifying the business object type
    objectDataSource.DataMember = "GetProducts"; // Specifying the name of the data object method
 
    // Assigning the ObjectDataSource component to the DataSource property of the report.
    report.DataSource = objectDataSource;
 
    // Assigning the report to the report viewer.
    reportViewer1.Report = report;
}
 
private void MainForm_Load(object sender, System.EventArgs e)
{
    this.reportViewer1.RefreshReport();
}

Additionally you may find useful How to: Bind to a BusinessObject help article.

Kind regards,
Peter
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Daniel
Top achievements
Rank 1
answered on 20 Jan 2012, 02:29 PM
Thanks for the reply, will try out what you've suggested and get back to you.
Tags
General Discussions
Asked by
Daniel
Top achievements
Rank 1
Answers by
Peter
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or