Skip to content

Commit de22481

Browse files
added KB with short videos in gif format for Creating User Functions … (#1667)
* added KB with short videos in gif format for Creating User Functions in Visual Studio Report Designer * another KN - Using the ObjectDataSource Component in Visual Studio Report Designer * Update creating-user-functions-in-vs-designer.md --------- Co-authored-by: Todor Arabadzhiev <todor.arabadzhiev@progress.com>
1 parent 5544194 commit de22481

File tree

4 files changed

+146
-0
lines changed

4 files changed

+146
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
title: Creating User Functions in Visual Studio Report Designer
3+
description: Learn how to create custom user functions in VS Report Designer.
4+
type: how-to
5+
page_title: How to Create and Utilize User Functions in VS Report Designer
6+
slug: creating-user-functions-in-vs-designer
7+
tags: reporting, user, function, designer, vs, visual, studio, net, framework
8+
res_type: kb
9+
ticketid: 1680822
10+
---
11+
12+
## Environment
13+
14+
| Version | Product | Author |
15+
| ---- | ---- | ---- |
16+
| | Visual Studio Report Designer |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)|
17+
18+
## Description
19+
20+
This tutorial shows how to create and utilize custom [user functions]({%slug telerikreporting/designing-reports/connecting-to-data/expressions/extending-expressions/user-functions%}) in the [Visual Studio Report Designer]({%slug telerikreporting/designing-reports/report-designer-tools/desktop-designers/visual-studio-report-designer/overview%}).
21+
22+
## Solution
23+
24+
Let's start with creating a Class library (**.NET Framework**) project and add a **Report** class using the [Item Templates]({%slug treporting-integration-with-visual-studio%}) in Visual Studio.
25+
26+
### User Functions Defined in the Report class
27+
28+
If your custom user function as a **public static** (**Public Shared** in *VB.NET*) method is a part of the current Report class:
29+
30+
````CSharp
31+
public partial class Report1 : Telerik.Reporting.Report
32+
{
33+
public Report1()
34+
{
35+
InitializeComponent();
36+
}
37+
38+
[Function(IsVisible = true, Category = "My Functions", Namespace = "My", Description = "Say Hi")]
39+
public static string Greet(string name)
40+
{
41+
return string.Format("Hello, {0}", name);
42+
}
43+
}
44+
````
45+
46+
It can be invoked from an expression by its name, specifying the necessary parameters in the braces, e.g., setting the **Value** of a **TextBox** to:
47+
48+
````
49+
= Greet("Dess")
50+
````
51+
52+
![User Function in Report class](images/user-function-in-report.gif)
53+
54+
### User Functions Defined in an External Assembly
55+
56+
1. If your custom user functions are linked from an external assembly (e.g., MyFunctions.dll), for the designer to recognize them, you will have to extend the configuration of the start application.
57+
58+
For the Visual Studio Report Designer, this is the **'devenv.exe.config'** file that resides in *'C:\Program Files (x86)\Microsoft Visual Studio X.0\Common7\IDE'* by default (it is recommended to create a backup copy before modifying it).
59+
60+
>important Do not forget to close the Visual Studio instance before modifying its configuration file. Run `Notepad` (or other editing tool) as an administrator to perform the changes.
61+
62+
````XML
63+
<configSections>
64+
<section
65+
name="Telerik.Reporting"
66+
type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting"
67+
allowLocation="true"
68+
allowDefinition="Everywhere"/>
69+
</configSections>
70+
<Telerik.Reporting>
71+
<AssemblyReferences>
72+
<add name="MyFunctions" />
73+
</AssemblyReferences>
74+
</Telerik.Reporting>
75+
````
76+
77+
78+
1. Copy the custom assembly in the same folder as the devenv.exe.config.
79+
1. You can type the expression by specifying the full name of the function and passing a parameter of the expected type.
80+
81+
````
82+
= MyFunctions.GetImageFromURL("image url")
83+
````
84+
85+
The custom function accepts an image url and returns an Image object that can be assigned to a PictureBox:
86+
87+
![User Function in External assembly](images/user-function-in-external-assembly.gif)
88+
89+
## See Also
90+
91+
- [Visual Studio Templates]({%slug treporting-integration-with-visual-studio%})
92+
- [Custom User Functions]({%slug telerikreporting/designing-reports/connecting-to-data/expressions/extending-expressions/user-functions%})
4.07 MB
Loading
1.18 MB
Loading
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: Using the ObjectDataSource Component in Visual Studio Report Designer
3+
description: Learn how to configure the ObjectDataSource Component in VS Report Designer.
4+
type: how-to
5+
page_title: How Configure the ObjectDataSource Component in VS Report Designer
6+
slug: using-objectdatasource-in-vs-designer
7+
tags: reporting, object, data, source, objectdatasource, designer, vs, visual, studio, net, framework
8+
res_type: kb
9+
---
10+
11+
## Environment
12+
13+
| Version | Product | Author |
14+
| ---- | ---- | ---- |
15+
| 19.0.25.313 | Visual Studio Report Designer |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)|
16+
17+
## Description
18+
19+
This tutorial shows how to configure and use the [ObjectDataSource]({%slug telerikreporting/designing-reports/connecting-to-data/data-source-components/objectdatasource-component/overview%}) component in the [Visual Studio Report Designer]({%slug telerikreporting/designing-reports/report-designer-tools/desktop-designers/visual-studio-report-designer/overview%}) while creating a Report.
20+
21+
## Solution
22+
23+
1\. Let's start with creating a Class library (**.NET Framework**) project (e.g. CarsLibraryDemo) that will be used as a data collection for feeding the [ObjectDataSource]({%slug telerikreporting/designing-reports/connecting-to-data/data-source-components/objectdatasource-component/connecting-the-objectdatasource-component-to-a-data-source%}). Build the project to produce a dll in the bin folder.
24+
25+
2\. Create another Class library (**.NET Framework**) project and add a **Report** class using the [Item Templates]({%slug treporting-integration-with-visual-studio%}) in Visual Studio. Add a reference to the Class Library project or to the dll which contains the data source definition.
26+
27+
3\. Extend the Visual Studio Report Designer by adding an AssemblyReferences in Telerik.Reporting section of application configuration file. The **'devenv.exe.config'** file resides in *'C:\Program Files (x86)\Microsoft Visual Studio X.0\Common7\IDE'* by default (it is recommended to create a backup copy before modifying it).
28+
29+
````XML
30+
<?xml version="1.0"?>
31+
<configuration>
32+
<configSections>
33+
<section name="Telerik.Reporting" type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting" allowLocation="true" allowDefinition="Everywhere" />
34+
</configSections>
35+
...
36+
<Telerik.Reporting>
37+
<assemblyReferences>
38+
<add name="yourAssemblyName"/>
39+
</assemblyReferences>
40+
</Telerik.Reporting>
41+
...
42+
</configuration>
43+
````
44+
45+
>important Do not forget to close the Visual Studio instance before modifying its configuration file. Run `Notepad` (or other editing tool) as administrator to perform the changes.
46+
47+
![ObjectDataSource from an External assembly](images/objectdatasource-populated-from-external-assembly-in-vs-designer.gif)
48+
49+
50+
## See Also
51+
52+
- [Visual Studio Templates]({%slug treporting-integration-with-visual-studio%})
53+
- [Connecting the ObjectDataSource component to a Data Source]({%slug telerikreporting/designing-reports/connecting-to-data/data-source-components/objectdatasource-component/connecting-the-objectdatasource-component-to-a-data-source%})
54+
- [Binding ObjectDataSource Component to a BusinessObject]({%slug telerikreporting/designing-reports/connecting-to-data/data-source-components/objectdatasource-component/how-to/how-to-bind-to-a-businessobject%})

0 commit comments

Comments
 (0)