Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to call ComponentOne controls under Winform and WPF

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report