Page 1 of 1

Exception when Calling the Editor at runtime

Posted: Wed May 31, 2006 3:38 pm
by 9640594
Hello,

On a base form I have put an Editor:

Code: Select all

private Steema.TeeChart.Editor editor1;
On inherited Forms I want to assign the Editor when a contextMenu is popped up which I do by writing:

Code: Select all

		private void contextMenuChart_Popup(object sender, System.EventArgs e)
		{
			m_ContextChart = (Steema.TeeChart.TChart) ((System.Windows.Forms.ContextMenu) sender).SourceControl;
		}
then when the context menu item is clicked I want to show the editor. I try this:

Code: Select all

			editor1.Chart = m_ContextChart;
			editor1.ShowModal();
But I get the following exception:
Object reference not set to an instance of an object.

Stack Trace: at Steema.TeeChart.Editors.ChartEditor..ctor(Chart c)
at Steema.TeeChart.Editor.ShowModal(Control owner)
at Steema.TeeChart.Editor.ShowModal()
at SWS_Data_Enhancer.Forms.FormChildStd.mnuChartEditor_Click(Object sender, EventArgs e) in c:\dev\c#\client apps\sws data enhancer\forms\formchildstd.cs:line 177
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItemData.Execute()
at System.Windows.Forms.Command.Invoke()
at System.Windows.Forms.Command.DispatchID(Int32 id)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
Can anyone help please?
I use VS2003.
thanks.

Posted: Thu Jun 01, 2006 10:46 am
by narcis
Hi whatever,

The problem may be related to having the editor declared as private, to be visible from an inherited form you should declare it as protected.

I'm also going to send you, to your forums contact e-mail, a working example.

The problem is not linked to the visibility of the Editor

Posted: Thu Jun 01, 2006 11:01 am
by 9640594
Thank you for your reply but the Editor should be private (I tried protected and it does not change anything).

All the code I wrote is in the base form so that there is no need to duplicate the call to editor.ShowModal() in inherited forms. I simply need to assign the ContextMenu at design time for the charts requiring the editor facility and the job is done (standard oop design principle).

I will try to update the chart with a newer version and let you know if that solves anything.

Thanks

Reinstalling the latest version did the trick!

Posted: Thu Jun 01, 2006 12:02 pm
by 9640594
Thanks.