如何正确继承图表控件 [英] How to properly inherit a chart control

查看:81
本文介绍了如何正确继承图表控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我可以在Visual Studio c ++ .net或c#中执行此操作,但问题是:如何继承Forms DataVisualization Chart控件并使用各种东西对其进行自定义,然后可以将其添加到toobox然后使用对于其他VS C ++ .net表单和C#项目?



我的意思是我已经这样做了,但我从来没有得到任何稳定的东西。当我将它添加到其他项目时,我或者得到有关ChartArea,Title和Series已经存在的错误,或者,工具箱将不接受新控件,因为它表示它与当前(这意味着任何)项目不兼容等等。


我只想继承Chart控件,然后为它编写一些动作,例如用于缩放的鼠标滚轮,用于各种交互的上下文菜单,用于自定义ChartArea和所选系列的辅助表单等。我有所有代码,当我可以将控件添加到其他项目等时它可以工作。



当x64项目在x86中构建时,尝试将控件添加到x64项目时总会遇到麻烦,反之亦然,有时甚至x86版本都说它与其他x86项目不兼容它是如此不可预测。



最简单的事情是制作一个Forms项目,然后添加一个完全对接的Chart控件,然后,在添加到其他项目时,这会创建更稳定的结果。但我想要的是能够将这个自定义Chart控件嵌入到其他现有的Form项目中,而不是作为一个单独的窗口。



我总能添加基本的Chart控件当然,对于任何类型的项目,然后复制其中的所有代码以与图表交互。但是,当然,这有点痛苦,只需拥有一个可以添加到任何项目的自定义继承图表,然后在设计师视图中查看等等将是很好的。



通常我会在VS c ++中写这个,但我也可以做c#也好。



我尝试了什么:



尝试过c#,VS c ++等继承。永远不要从工具箱中无缝地插入其他项目。

解决方案

你没有正确地继承......这是矛盾的。



创建一个容器控件(用于图表) )做它(通常)需要做的事情。



添加容器(用户控件;自定义控件),它将图表托管到您的项目中(或多个)。

So I can do this in either Visual Studio c++ .net or c#, but the question is: How does one inherit the Forms DataVisualization Chart control and customize it with various things which can then be added to the toobox to then be used for other VS C++ .net Forms and C# projects?

I mean I have done this already, but I never get anything stable. When I add it to other projects, I either get errors about the ChartArea, Title, and Series already existing, or, the toolbox won't accept the new control because it is says it is incompatible with the current (which means any) project, etc.

I just want to inherit the Chart control and then program some actions for it, such as the mouse wheel for zooming, a context menu for various interactions, a secondary Form for customizing the ChartArea and selected Series, etc. I have all that code, and it works when I can get the control to be added to other projects, etc.

It is just that there is always trouble, when say, trying to add the control to an x64 project when it was built in x86, and vice-versa, and sometimes even the x86 version says it is incompatible with other x86 projects, etc. It's just so unpredictable.

The simplest thing is to make a Forms project, and then add a Chart control with full docking to it, and then this creates more stable results when adding to other projects. But what I want is to be able to embed this custom Chart control into other existing Form projects and not as a separate window.

I can always add the basic Chart control to any type of project, of course, and then copy all of the code in there for interacting with the chart. But of course, that's a bit of a pain and it would be nice to simply have a customized inherited Chart that can be added to any project, and then viewed in designer view, etc.

Typically I would write this in VS c++, but I can do c# just fine as well.

What I have tried:

Have tried inheritance in c#, VS c++, etc. Never get anything that seamlessly drops into other projects from the Toolbox.

解决方案

You don't "properly inherit" ... it's an oxymoron.

Create a "container" control (for the chart) that "does what it (commonly) needs to do".

Add the "container" (user control; custom control) which hosts the chart to your project(s).


这篇关于如何正确继承图表控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆