This example shows the possibility of using User Data in a report. For this purpose you can use the
StiUserData
class, which is registered as report data.
StiUserData
is Stimulsoft data type that provides the ability to create a report, based on the untyped and not structured data. For example, services, business objects, etc.
StiUserData
can be used when working with large volumes of data. For example, using standard .NET methods, you could run out of memory. In this case, the solution would be to use custom data sources.
Register the necessary data in the report:
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
stiReport1.RegData("HatchStyleEnum", Enum.GetNames(typeof(HatchStyle)));
Type type = typeof(Graphics);
assemblys = type.GetMethods();
stiUserData1.Count = assemblys.Length;
stiReport1.RegData("UserData", stiUserData1);
}
The specified class has a
GetData()
event, which occurs when a report generator request a data. For example, the event returns information about the Graphics system assemblies:
private void stiUserData1_GetData(object sender, Stimulsoft.Report.Dictionary.StiUserGetDataEventArgs e)
{
if (e.ColumnName == "Name") e.Data = assemblys[e.Position].Name;
if (e.ColumnName == "ReturnType") e.Data = assemblys[e.Position].ReturnType.Name;
if (e.ColumnName == "IsStatic") e.Data = assemblys[e.Position].IsStatic;
if (e.ColumnName == "Parameters")
{
ParameterInfo[] pars = assemblys[e.Position].GetParameters();
string s = string.Empty;
foreach (ParameterInfo par in pars)
s += par.ParameterType.Name + " " + par.Name + "\n";
e.Data = s;
}
}
Auf dem Screenshot unten Sie können das Ergebnis des Beispiel-Codes ansehen: