User (Legacy) Posted April 24, 2003 Report Share Posted April 24, 2003 I'm getting the following error:- An unhandled exception of type 'System.NullReferenceException' occurred in chartfx.base.dll Additional information: Object reference not set to an instance of an object. Unhandled Exception: The program '[3060] WindowsApplication8.exe' has exited with code 0 (0x0). System.NullReferenceException: Object reference not set to an instance of an object. at SoftwareFX.ChartFX.Base.ToolItem.set_CommandID(Int32 value) at SoftwareFX.ChartFX.Base.ToolItem..ctor(ToolBar toolBar, Int32 nID) at SoftwareFX.ChartFX.Base.ToolBar.set_Item(Int32 n, Int32 value) at WindowsApplication8.Form1..ctor() in c:\dev.net\test\winforms\chartfxtest\form1.cs:line 35 at WindowsApplication8.Form1.Main() in c:\dev.net\test\winforms\chartfxtest\form1.cs:line 109 My code is below, what am I doing wrong here ? using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using SoftwareFX.ChartFX; namespace WindowsApplication8 { /// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form { private SoftwareFX.ChartFX.Chart chart1; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); const int customID = 8; chart1.Commands.AddCommand(customID); chart1.Commands[customID].Style = CommandStyle.Selector; // chart1.Commands[customID].Picture = 2; chart1.Commands[customID].Text = "TEst Toool"; chart1.ToolBarObj.InsertAt(3, 1); chart1.ToolBarObj[3] = customID; } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { SoftwareFX.ChartFX.Borders.GradientBackground gradientBackground1 = new SoftwareFX.ChartFX.Borders.GradientBackground(); this.chart1 = new SoftwareFX.ChartFX.Chart(); this.SuspendLayout(); // // chart1 // this.chart1.Name = "chart1"; this.chart1.Size = new System.Drawing.Size(663, 341); this.chart1.TabIndex = 0; this.chart1.ToolBar = true; this.chart1.UserCommand += new SoftwareFX.ChartFX.CommandUIEventHandler(this.chart1_UserCommand); // // Form1 // this.ClientSize = new System.Drawing.Size(704, 375); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.chart1}); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); } #endregion /// <summary> /// The main entry point for the application. /// </summary> [sTAThread] static void Main() { Application.Run(new Form1()); } private void chart1_UserCommand(object sender, SoftwareFX.ChartFX.CommandUIEventArgs e) { if (e.ID == 4) MessageBox.Show("Test tool"); } } } Link to comment Share on other sites More sharing options...
User (Legacy) Posted April 24, 2003 Author Report Share Posted April 24, 2003 I forgot one detail... the error is occuring on the following line in the code:- chart1.ToolBarObj[3] = customID; "Michael Lang" <michael@fusiongrp.com> wrote in message news:V3vZT1iCDHA.2752@webserver1.softwarefx.com... > I'm getting the following error:- > > An unhandled exception of type 'System.NullReferenceException' occurred in > chartfx.base.dll > Additional information: Object reference not set to an instance of an > object. > > Unhandled Exception: The program '[3060] WindowsApplication8.exe' has exited > with code 0 (0x0). > System.NullReferenceException: Object reference not set to an instance of an > object. > at SoftwareFX.ChartFX.Base.ToolItem.set_CommandID(Int32 value) > at SoftwareFX.ChartFX.Base.ToolItem..ctor(ToolBar toolBar, Int32 nID) > at SoftwareFX.ChartFX.Base.ToolBar.set_Item(Int32 n, Int32 value) > at WindowsApplication8.Form1..ctor() in > c:\dev.net\test\winforms\chartfxtest\form1.cs:line 35 > at WindowsApplication8.Form1.Main() in > c:\dev.net\test\winforms\chartfxtest\form1.cs:line 109 > > My code is below, what am I doing wrong here ? > > using System; > using System.Drawing; > using System.Collections; > using System.ComponentModel; > using System.Windows.Forms; > using System.Data; > using SoftwareFX.ChartFX; > > namespace WindowsApplication8 > { > /// <summary> > /// Summary description for Form1. > /// </summary> > public class Form1 : System.Windows.Forms.Form > { > private SoftwareFX.ChartFX.Chart chart1; > /// <summary> > /// Required designer variable. > /// </summary> > private System.ComponentModel.Container components = null; > > public Form1() > { > // > // Required for Windows Form Designer support > // > InitializeComponent(); > > const int customID = 8; > chart1.Commands.AddCommand(customID); > chart1.Commands[customID].Style = CommandStyle.Selector; > // chart1.Commands[customID].Picture = 2; > chart1.Commands[customID].Text = "TEst Toool"; > chart1.ToolBarObj.InsertAt(3, 1); > chart1.ToolBarObj[3] = customID; > } > > /// <summary> > /// Clean up any resources being used. > /// </summary> > protected override void Dispose( bool disposing ) > { > if( disposing ) > { > if (components != null) > { > components.Dispose(); > } > } > base.Dispose( disposing ); > } > > #region Windows Form Designer generated code > /// <summary> > /// Required method for Designer support - do not modify > /// the contents of this method with the code editor. > /// </summary> > private void InitializeComponent() > { > SoftwareFX.ChartFX.Borders.GradientBackground gradientBackground1 = new > SoftwareFX.ChartFX.Borders.GradientBackground(); > this.chart1 = new SoftwareFX.ChartFX.Chart(); > this.SuspendLayout(); > // > // chart1 > // > this.chart1.Name = "chart1"; > this.chart1.Size = new System.Drawing.Size(663, 341); > this.chart1.TabIndex = 0; > this.chart1.ToolBar = true; > this.chart1.UserCommand += new > SoftwareFX.ChartFX.CommandUIEventHandler(this.chart1_UserCommand); > // > // Form1 > // > this.ClientSize = new System.Drawing.Size(704, 375); > this.Controls.AddRange(new System.Windows.Forms.Control[] { > this.chart1}); > this.Name = "Form1"; > this.Text = "Form1"; > this.ResumeLayout(false); > > } > #endregion > > /// <summary> > /// The main entry point for the application. > /// </summary> > [sTAThread] > static void Main() > { > Application.Run(new Form1()); > } > > private void chart1_UserCommand(object sender, > SoftwareFX.ChartFX.CommandUIEventArgs e) > { > if (e.ID == 4) > MessageBox.Show("Test tool"); > } > } > } > > Link to comment Share on other sites More sharing options...
Software FX Posted April 24, 2003 Report Share Posted April 24, 2003 A CommandStyle.Selector is a command that allows you to select from several options, the exception you are getting is because you have not added any options to it. What exactly do you want to add to the toolbar ? a drop-down list ? the follwoing code creates CommandStyle.Selector with 2 options. Command cmd; const int customID = 8; const int customID2 = 9; const int customID3 = 10; cmd = chart1.Commands.AddCommand(customID2); cmd.Style = CommandStyle.GroupHead | CommandStyle.TwoState; cmd.Text = "1"; cmd = chart1.Commands.AddCommand(customID3); cmd.Style = CommandStyle.GroupHead | CommandStyle.TwoState; cmd.Text = "2"; cmd = chart1.Commands.AddCommand(customID); cmd.Style = CommandStyle.Selector; cmd.Text = "Test Toool"; cmd.InsertSubCommands(2,0); cmd.SubCommandID[0] = customID2; cmd.SubCommandID[1] = customID3; chart1.ToolBarObj.InsertAt(3, 1); chart1.ToolBarObj[3] = customID; -- FP Software FX, Inc. Link to comment Share on other sites More sharing options...
Software FX Posted April 24, 2003 Report Share Posted April 24, 2003 The exception is caused because you are setting the Style for this command item to be a selector. If you want a "check-box" behavior you should set the Style to be TwoState. -- Regards, JC Software FX Support "Michael Lang" <michael@fusiongrp.com> wrote in message news:Gq6ZiljCDHA.2264@webserver1.softwarefx.com... > I forgot one detail... the error is occuring on the following line in the > code:- > > chart1.ToolBarObj[3] = customID; > > > "Michael Lang" <michael@fusiongrp.com> wrote in message > news:V3vZT1iCDHA.2752@webserver1.softwarefx.com... > > I'm getting the following error:- > > > > An unhandled exception of type 'System.NullReferenceException' occurred in > > chartfx.base.dll > > Additional information: Object reference not set to an instance of an > > object. > > > > Unhandled Exception: The program '[3060] WindowsApplication8.exe' has > exited > > with code 0 (0x0). > > System.NullReferenceException: Object reference not set to an instance of > an > > object. > > at SoftwareFX.ChartFX.Base.ToolItem.set_CommandID(Int32 value) > > at SoftwareFX.ChartFX.Base.ToolItem..ctor(ToolBar toolBar, Int32 nID) > > at SoftwareFX.ChartFX.Base.ToolBar.set_Item(Int32 n, Int32 value) > > at WindowsApplication8.Form1..ctor() in > > c:\dev.net\test\winforms\chartfxtest\form1.cs:line 35 > > at WindowsApplication8.Form1.Main() in > > c:\dev.net\test\winforms\chartfxtest\form1.cs:line 109 > > > > My code is below, what am I doing wrong here ? > > > > using System; > > using System.Drawing; > > using System.Collections; > > using System.ComponentModel; > > using System.Windows.Forms; > > using System.Data; > > using SoftwareFX.ChartFX; > > > > namespace WindowsApplication8 > > { > > /// <summary> > > /// Summary description for Form1. > > /// </summary> > > public class Form1 : System.Windows.Forms.Form > > { > > private SoftwareFX.ChartFX.Chart chart1; > > /// <summary> > > /// Required designer variable. > > /// </summary> > > private System.ComponentModel.Container components = null; > > > > public Form1() > > { > > // > > // Required for Windows Form Designer support > > // > > InitializeComponent(); > > > > const int customID = 8; > > chart1.Commands.AddCommand(customID); > > chart1.Commands[customID].Style = CommandStyle.Selector; > > // chart1.Commands[customID].Picture = 2; > > chart1.Commands[customID].Text = "TEst Toool"; > > chart1.ToolBarObj.InsertAt(3, 1); > > chart1.ToolBarObj[3] = customID; > > } > > > > /// <summary> > > /// Clean up any resources being used. > > /// </summary> > > protected override void Dispose( bool disposing ) > > { > > if( disposing ) > > { > > if (components != null) > > { > > components.Dispose(); > > } > > } > > base.Dispose( disposing ); > > } > > > > #region Windows Form Designer generated code > > /// <summary> > > /// Required method for Designer support - do not modify > > /// the contents of this method with the code editor. > > /// </summary> > > private void InitializeComponent() > > { > > SoftwareFX.ChartFX.Borders.GradientBackground gradientBackground1 = new > > SoftwareFX.ChartFX.Borders.GradientBackground(); > > this.chart1 = new SoftwareFX.ChartFX.Chart(); > > this.SuspendLayout(); > > // > > // chart1 > > // > > this.chart1.Name = "chart1"; > > this.chart1.Size = new System.Drawing.Size(663, 341); > > this.chart1.TabIndex = 0; > > this.chart1.ToolBar = true; > > this.chart1.UserCommand += new > > SoftwareFX.ChartFX.CommandUIEventHandler(this.chart1_UserCommand); > > // > > // Form1 > > // > > this.ClientSize = new System.Drawing.Size(704, 375); > > this.Controls.AddRange(new System.Windows.Forms.Control[] { > > this.chart1}); > > this.Name = "Form1"; > > this.Text = "Form1"; > > this.ResumeLayout(false); > > > > } > > #endregion > > > > /// <summary> > > /// The main entry point for the application. > > /// </summary> > > [sTAThread] > > static void Main() > > { > > Application.Run(new Form1()); > > } > > > > private void chart1_UserCommand(object sender, > > SoftwareFX.ChartFX.CommandUIEventArgs e) > > { > > if (e.ID == 4) > > MessageBox.Show("Test tool"); > > } > > } > > } > > > > > > Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.