Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 30th, 2007, 07:28 AM
Authorized User
 
Join Date: Oct 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error when adding a ToolStripMenuItem

I am having trouble adding a ToolStripMenuItem but I do not know why. I have so far added many ToolStripMenuItems as follows:

File
New
Save
Save As
Print
Close

Format
Font
Colour

Help
Contents
Index
Search
About

I want to add 3 more items under the Format menu, these being: Bold, Italic, Underlined.
Each time I click on the drop down menu at design time and type Bold where it says 'Type Here' and then click away (This menu item with the text Bold should be saved) but the new menu item disappears as though I have not typed anything. When I try to type Bold again this error appears in a dialog box:

The control System.Windows.Forms.TextBox has thrown an unhandled exception in the designer and has been disabled.
Exception:
Object reference not set to an instance of an object.
Stack trace:

I then get an error from Visual Studio saying:

Microsoft Visual Studio has encounted a problem and needs to close.

Also in this dialog box, there are 3 buttons, Debug, Send Error Report and Don't Send.
Can anyone advise me as to what is going wrong when I try to add a ToolStripMenuItem?

Lucy
 
Old October 30th, 2007, 07:39 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

It sounds like the form code has become corrupt. Are you able to view the code behind and see if there is a 'bold' menu item already defined?

/- Sam Judson : Wrox Technical Editor -/
 
Old October 30th, 2007, 07:55 AM
Authorized User
 
Join Date: Oct 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In the Designer.cs of the form Bold is not already defined. I can add menu items with coding in this file with no errors but not during design time.

Lucy





Similar Threads
Thread Thread Starter Forum Replies Last Post
ToolStripMenuItem Enter & Leave Event angelboy C# 2005 6 November 21st, 2008 04:57 PM
custom delegate for ToolStripMenuItem maricar C# 4 September 4th, 2008 03:07 AM
Error adding DLL jayznz VS.NET 2002/2003 3 June 12th, 2008 12:15 PM
Error adding a check constraint SQLScott SQL Server 2005 2 October 3rd, 2007 05:58 AM
Question about error after adding serialization... davidd31415 BOOK: Ivor Horton's Beginning Visual C++ 2005 1 December 28th, 2006 04:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.