We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Object Reference Not Set When Placing Chart on Form

Thread ID:

Created:

Updated:

Platform:

Replies:

33799 Aug 26,2005 06:20 AM Aug 31,2005 09:42 AM Windows Forms 5
loading
Tags: Chart
Hamish Gunn
Asked On August 26, 2005 06:20 AM

I received this message when I try to compile. My chart became a box with a red border and a trace message inside ("System.NullReferenceException..."). Somehow or other I managed to get this to run and the chart appeared at run time. Now however the chart appears at design time but my program appears to compile but I get the message Object Reference Not Set when the form tries to load. The Stack Trace starts StackTrace " at Syncfusion.Windows.Forms.Chart.ChartLegend.AutoSize(Rectangle rect) at Syncfusion.Windows.Forms.Chart.ChartLegend.AutoLocation(Rectangle rect) at Syncfusion.Windows.Forms.Chart.ChartControl.RecalculateSizes() at Syncfusion.Windows.Forms.Chart.ChartLegend.OnRecalculateSizes() at Syncfusion.Windows.Forms.Chart.ChartLegend.OnLegentSizeChange() at Syncfusion.Windows.Forms.Chart.ChartLegend.set_CustomItems(LegendItem[] value) This seems to be a legend problem. I''ve re-installed Syncfusion and Studio but still have the problem. I can''t keep replacing the Chart on the form as it is too time consuming.

Hamish Gunn
Replied On August 26, 2005 06:37 AM

The problem appears to be that the Chart Designer is not creating the Legend. The error occurs at the line which Adds a Legend. The parameter is a ChartLegend object: '' ''chrtOutput '' Me.chrtOutput.BackColor = System.Drawing.Color.White Me.chrtOutput.Controls.Add(Me.chrtOutput.Legend) ... - Me.chrtOutput.Legend {Syncfusion.Windows.Forms.Chart.ChartLegend} Syncfusion.Windows.Forms.Chart.ChartLegend + AccessibilityObject {System.Windows.Forms.Control.ControlAccessibleObject} System.Windows.Forms.AccessibleObject AccessibleDefaultActionDescription Nothing String AccessibleDescription Nothing String AccessibleName Nothing String AccessibleRole Default System.Windows.Forms.AccessibleRole AllowDrop False Boolean Anchor 9 System.Windows.Forms.AnchorStyles + BackColor {System.Drawing.Color} System.Drawing.Color BackgroundImage Nothing System.Drawing.Image BindingContext Nothing System.Windows.Forms.BindingContext + Border {Syncfusion.Windows.Forms.Chart.LineInfo} Syncfusion.Windows.Forms.Chart.LineInfo Bottom 48 Integer + Bounds {System.Drawing.Rectangle} System.Drawing.Rectangle CanFocus False Boolean CanSelect True Boolean Capture False Boolean CausesValidation True Boolean + ClientRectangle {System.Drawing.Rectangle} System.Drawing.Rectangle + ClientSize {System.Drawing.Size} System.Drawing.Size Columns 1 Integer CompanyName "Syncfusion, Inc." String Container Nothing System.ComponentModel.IContainer ContainsFocus False Boolean ContextMenu Nothing System.Windows.Forms.ContextMenu + Controls {System.Windows.Forms.Control.ControlCollection} System.Windows.Forms.Control.ControlCollection Created True Boolean + Cursor {System.Windows.Forms.Cursor} System.Windows.Forms.Cursor CustomItems {Length=0} Syncfusion.Windows.Forms.Chart.LegendItem() + DataBindings {System.Windows.Forms.ControlBindingsCollection} System.Windows.Forms.ControlBindingsCollection + DefaultBackColor {System.Drawing.Color} System.Drawing.Color + DefaultFont {System.Drawing.Font} System.Drawing.Font + DefaultForeColor {System.Drawing.Color} System.Drawing.Color + DisplayRectangle {System.Drawing.Rectangle} System.Drawing.Rectangle Disposing False Boolean Dock None System.Windows.Forms.DockStyle Enabled True Boolean FloatingAutoSize True Boolean Focused False Boolean + Font {System.Drawing.Font} System.Drawing.Font + ForeColor {System.Drawing.Color} System.Drawing.Color Handle 2035040 System.IntPtr HasChildren False Boolean Height 28 Integer ImeMode NoControl System.Windows.Forms.ImeMode InvokeRequired False Boolean IsAccessible False Boolean IsDisposed False Boolean IsHandleCreated True Boolean ItemsAlignment Near System.Drawing.StringAlignment Left 162 Integer LegendAlignment Center System.Drawing.StringAlignment + Location {System.Drawing.Point} System.Drawing.Point ModifierKeys None System.Windows.Forms.Keys MouseButtons None System.Windows.Forms.MouseButtons + MousePosition {System.Drawing.Point} System.Drawing.Point Name "" String Orientation Horizontal System.Windows.Forms.Orientation + Parent {Syncfusion.Windows.Forms.Chart.ChartControl} System.Windows.Forms.Control Position Top Syncfusion.Windows.Forms.Chart.ChartLegendPosition ProductName "Essential Chart" String ProductVersion "3.201.1.0" String RecreatingHandle False Boolean Region Nothing System.Drawing.Region RepresentationType SeriesType Syncfusion.Windows.Forms.Chart.ChartLegendRepresentationType Right 238 Integer RightToLeft No System.Windows.Forms.RightToLeft Rows 1 Integer ShowBorder True Boolean ShowSymbol False Boolean Site Nothing System.ComponentModel.ISite + Size {System.Drawing.Size} System.Drawing.Size Spacing 4 Integer TabIndex 3 Integer TabStop True Boolean Tag Nothing Object Text "" String Top 20 Integer TopLevelControl Nothing System.Windows.Forms.Control Visible True Boolean Width 76 Integer + WindowTarget {System.Windows.Forms.Control.ControlNativeWindow} System.Windows.Forms.IWindowTarget

Hamish Gunn
Replied On August 26, 2005 07:23 AM

The legend customitems had an item of nothing. I removed this from the code and I appear to be back working.

Administrator [Syncfusion]
Replied On August 26, 2005 11:51 AM

Hi, Thanks for the feedback. We are currently working on optimizing the initial code that is serialized when the ChartControl is added to the form. The legend should not be created explicitly and added to the chartcontrol - it should be internal. We should have these changes done within the next few weeks. Thanks, Davis

Hamish Gunn
Replied On August 31, 2005 04:30 AM

I have set up a DirectTrac incident. I am not manually creating a Legend, it is the designer. It generates a line of code: Me.chrtOutput.Legend.CustomItems = New Syncfusion.Windows.Forms.Chart.LegendItem() {Nothing} which appears to be the problem. I comment it out and things seem to work. Thanks

Administrator [Syncfusion]
Replied On August 31, 2005 09:42 AM

Hi, Sorry I wasn''t clear. I was just commenting that the code generation for the ChartControl should keep the legend internal. Regards, Davis

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;