Get the App
SLTechnology News&Howtos  ›  Development  › 

How to call ComponentOne controls under Winform and WPF

Shulou Source: shulou.com Published: 2022-06-02 09:26:51 10月01日 Update

This article mainly shows you "how to call ComponentOne controls under Winform and WPF". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn how to call ComponentOne controls under Winform and WPF.

Step 1

First of all, let's set up the basic communication channels of the two platforms. It is very simple. There are many steps on the Internet, which are mainly divided into three steps:

Add two references: WindowsFormsIntegration.dll (responsible for integrating WPF and Windows) and System.Windows.Forms.

Add two references (in bold) to the XAML file:

< /Window>

To explain, what this code really works is the reference WindowsFormsIntegration.dll, and this reference System.Windows.Forms refers to the Microsoft native control in Winform, so when using ComponentOne, you can not reference it.

Let's first look at an example: using Winform in WPF through Microsoft primitive controls, the code is as follows:

WindowsFormsHost is actually a container for Winform in WPF, so all Winform controls are displayed in this container.

Setp2

As we said above, we use FlexReport as the medium for communication, then we need to prepare a few small steps:

The template of FlexReport under Winform

Related citation

Note: the reference here is a reference to Winform. Again, we need to quote in xmal:

Xmlns:cc11= "clr-namespace:C1.Win.FlexViewer;assembly=C1.Win.FlexViewer.4"

Add controls to the layout for report preview

Setp3

We load the report in the background

Private C1FlexReport _ report; public Window1 () {InitializeComponent (); _ report = new C1FlexReport (); / / load report definition from resources Assembly asm = Assembly.GetExecutingAssembly (); using (Stream stream = asm.GetManifestResourceStream ("WpfApp1.Resources.FlexCommonTasks.flxr")) _ report.Load (stream, "Chart2D"); / / assign report to the preview pane flexViewerPane.DocumentSource = null; flexViewerPane.DocumentSource = _ report;}

Note: keep in mind that the reports here are from the Winform platform.

At this point, we have finished more than half of our work, and we are still short of the last step of turning stone into gold. Many people think that it is over here, but we have to consider the problem of ComponentOne License authorization. How to register the authorization of Winform under WPF is actually very simple, because the license mechanism of .NET is the same, we only need to register the license of the control in the same way, but manual registration is recommended here, which is very important, because if you are not careful, you will report the error of lc.exe=-1.

We all use it here.

C1FlexViewerPane

C1FlexReport

So we write the following registration information in the license file

C1.Win.FlexReport.C1FlexReport, C1.Win.FlexReport.4 C1.Win.FlexViewer.C1FlexViewerPane, C1.Win.FlexViewer.4

At this point, we are done.

These are all the contents of this article entitled "how to call ComponentOne controls under Winform and WPF". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Control two content report step article code original ecology container platform file face Microsoft learning help communication important done turn stone into gold accidentally Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn OPPO Reno Docker Linux Microsoft