C++/CLI - XML based active reports

回眸只為那壹抹淺笑 提交于 2019-12-11 20:31:58

问题


This is in continuation to one of my previous queries(active reports in C /CLI). I am accessing an xml-based active report from a C++/CLI application. Is there any way by which I can have a data communication with the active report from C++/CLI, for example, I want to print the managed data present in the C++/CLI application on the details section of the XML report which the application accesses. I don't want to use any c# code. Can it be done? Thanks.


回答1:


Sure, ActiveReports can do it. Since C++/CLI produces standard .NET objects you can create objects in C++/CLI and ActiveReports will bind to them. Create an IEnumerable collection of objects that you want to bind to (each object in the collection is like a database "row").

Take a look at the examples at Binding Reports to a Data Source. Expand the code sections under the heading To use the IEnumerable data source and you'll see how to do it in C#. You would do precisely the same thing in C++/CLI, you'll just change the syntax from C# to C++/CLI. Clearly, you know C++/CLI syntax so you can do that part, but I think this answers your question regarding how to do this with ActiveReports.

Update based on question asked in comments:

You should be able to handle an ActiveReports' event such as the FetchData event using something like the following code:

void MyFetchDataHandler(Object^ sender, FetchEventArgs^ eArgs) 
{
 //put handling code here...
}

myReport->FetchData += ref new FetchEventHandler(this, &MyClass::MyFetchDataHandler)

I didn't compile this (I don't have AR handy), but it should be close. Please see Microsoft's reference documentation on C++/CLI event syntax here.



来源:https://stackoverflow.com/questions/19892875/c-cli-xml-based-active-reports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!