Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted
Updated 20-Nov-18 8:25am
v2

1 solution

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).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900