Jump to content
Software FX Community

Inherit ChartFX.WinForms.Chart???


CalsepDK

Recommended Posts

Hi

I want to inherit your ChartFX.WinForms.Chart control and create a new UserControl with the basic behaviour plus some extended features needed across a number of our applications. There are some problems in doing this. To have a really clear example I have created a new usercontrol which inherits from the Chart (nothing new has been added to it yet). When I add this new UserControl to a form, it doesn't add my UserControl, it adds a ChartFX.WinForms.Chart instead! This is weird by itself, but okay, I go to the .Designer file (VB.Net) and change InitializeComponent to create my usercontrol instead of the added ChartFX,WinForms.Chart. It now works runtime, but design time, I cannot use the SmartTag "Chart task" to fi. "Configure axis and panes". It reports an error of "Object reference not set to an instance of an object".

We use a number of different usercontrol from other companies, like Infragistics and FarPoint, and we have not encountered this problem with inheriting their usercontrol while retaining the use of their Smart Tags.

We use a number of different usercontrol from other companies, like Infragistics and FarPoint, and we have not encountered this problem with inheriting their usercontrol while retaining the use of their Smart Tags.

It is really important that we can use inheritance, so any help is appreciated (we have a really simple example project if that is any help)...

*EDIT* Hmmm,  even worse than not being able to use the Smart Tags, it seems as thou the events for the mouse (move, click, etc) are not working when inheriting...

Regards

...Henrik

Link to comment
Share on other sites

Henrik,

Thank you for your feedback. Although was unable to reproduce the following:

> When I add this new UserControl to a form, it doesn't add my UserControl, it adds a ChartFX.WinForms.Chart instead!

I get my control to create.

> even worse than not being able to use the Smart Tags, it seems as thou the events for the mouse (move, click, etc) are not

> working when inheriting...

I get all mouse events perfectly (MouseClick, MouseDown,MouseUp)

 I did find a problem with the smart tag Wizard ("Object reference not set to an instance of an object" message). We fixed this problem internally but a Service Pack is not yet available. Please contact Software FX support to get a ccess to a HotFix that fixes this problem.

Link to comment
Share on other sites

Hi Frank

Will you please take a look at the attached project. It is extremely simple, but demontrates the behaviour described. Open it, build it and then try to add UserControl1 to the form. The control created on the form is of the type ChartFX.WinForms.Chart and not UserControl1 as expected.

The control that is already on the form has been added manually by changing the code in the .Designer file. I wanted to reproduce the mouse event problem I am having in our project, but it apparently works fine in the test project. The error we are facing in our project is:

"Error 1 Method 'Private Sub ChartPipeline_MouseClick(sender As Object, e As ChartFX.WinForms.HitTestEventArgs)' cannot handle Event 'Public Event MouseClick(sender As Object, e As ChartFX.WinForms.HitTestEventArgs)' because they do not have the same signature."

And this prevents us from compiling the project. A reason for this could perhaps be that in our project, the control is located in a separate assembly, but I still haven't been able to reproduce it in a simple test project.

I am very interested in hearing your feedback the control creation issue...

 Thanks

...Henrik

Link to comment
Share on other sites

I tried your project with the latest version (internal) and got the following results:

- MouseClick event: Works as expected. I get a Message Box when I run your app and click on the chart

- Smart-Tag Wizard: Works perfectly.

- Dropping a control on the form: This one is tricky because I don't know where you are dropping the control from. If I add the control to the toolbox from the EXE then I get the same behavior that you get. However, this is not right. The control should be in a dll not on a external exe, this may be the cause of the problem. When I did my tests I create a Windows Control Library (dll) and that's where I put the control that inherits from chart. In this scenario dropping the control works as expected.

 

Link to comment
Share on other sites

Hi again

 - MouseClick is working in the sample, yes, i couldn't recreate the error I get in my real project.

-  I will request the latest version to get SmartTag to work.

- I don't agree with your explanation of dropping the control on the form (except of course that it is tricky...). We have numerous other control in the same project which work without a glitch (and they also inherit other controls). I am pretty confident that it does not matter if the project is an exe or a dll, concerning controls (if it actually was the case, then why would MS allow you to add controls to an exe project?). Besides in our real project, the control is in a separate dll which contains a number of shared control used across our suite of applications. Could it be somewhere in your control that you explicitly return a Chart object instead of Me (fi. in CreateControl)? This could explain the behaviour...

I wouldn't mind seeing the test project you created. I cannot get it to work no matter which kind of project I use...

Regards

...Henrik

Link to comment
Share on other sites

Hi

 Yup, it worked. Adding <ComponentModel.ToolboxItem(True)> to my component, makes it create the correct control when adding it to a form. I can see this is also what you do in your testproject. I am not sure about C#, but in VB.net this tag is not required to make it a toolbox item and this is the only control in which it was needed for it to behave as expected.

Anyhow, it now works perfectly. It even got the mouse events to fire properly in our real project (which also is a bit odd, as I cannot see why it should be related...).

*EDIT*. Nope, the mouse events still doesn't fire correctly. Oddly enough, I got it working one time, but after enabling it on a few more forms, it failed again across the entire application. Our workaround is that we raise custom events ChartMouseClick, ChartMouseMove, etc. with a signature of "(sender as object, e as object)". If we declare "e as HitTestEventArgs" we get the same error as when we try to catch the original events (see below). I suspect it has something to do with references (the control and form are in separate projects), but both have the same version of ChartFX.WinForms... Quite peculiar, really...!?

Method 'Private Sub ChartPipeline_ChartClick(sender As Object, e As ChartFX.WinForms.HitTestEventArgs)' cannot handle Event 'Public Event ChartMouseClick(sender As Object, e AsChartFX.WinForms.HitTestEventArgs)' because they do not have the same signature. 

Thanks.

...Henrik

Link to comment
Share on other sites

> this is the only control in which it was needed for it to behave as expected

Most likely those other controls don't have a custom toolbox item. Because of our greater level of integration with Visual Studio we need one.

How are you declaring the event? The following works for me (you can try it in the control I sent you):

Private Sub InheritedChart1_MouseClick(ByVal sender As System.Object, ByVal e As ChartFX.WinForms.HitTestEventArgs) Handles InheritedChart1.MouseClick   MessageBox.Show("Click")

End Sub

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...