Tuesday, February 21, 2012

ReportViewer-winform

Is there a way to make the data selecatable. For example, a user runs a report and wants to copy the applicationId onto their clipboard so they can use it to search in another application. Currently they have to remember or write down a 9 digit number. Not very user friendly...

I am currently using a data table as the container for the data in my rdl file. Then I use reportviewer for winforms to embed it in our user application.

Thanks

hi mpetanovitch,

You can try this for each TextBox on the Report file.

Suppose there is a table item on the Report file,

Step 1:

At the DesignTime, for each TextBox in the 'Table Details' row :

Do RightClick then go to Properties-->Navigation-->Hyperlink Action

Select 'Jump to URL' and in the following ComboBox type '= "nolink:" & Fields!FieldName.Value'

In the 'Fields!FieldName.Value', replace 'FieldName' with name of the Field containig TextBox.

Step 2:

Put the following line in the ReportViewer1_Load :

this.ReportViewer1.LocalReport.EnableHyperlinks = true;

Step 3:

Add a Handler for the ReportViewer1_HyperLink event like this :

private void ReportViewer1_Hyperlink(object sender, HyperlinkEventArgs e)
{
Uri SelText = new Uri(e.Hyperlink);
if (SelText.Scheme.ToLower() == "nolink")
{
e.Cancel = true;
this.reportViewer1.Find(SelText.AbsolutePath, this.ReportViewer1.CurrentPage);
Clipboard.Clear();
Clipboard.SetText(SelText.AbsolutePath);
}
}

Regards
A. Cheraghi

No comments:

Post a Comment