Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear All
I have almost crated a notepad for using windows form and c#.net . In this application i have used a richTextBox and menustrip control, all coding i have done but word warp code not work, i have using this code but this code show an error "instance ref not set"
wordWrapToolStripMenuItem.Checked = !(wordWrapToolStripMenuItem.Checked);
richTextBox1.WordWrap = wordWrapToolStripMenuItem.Checked;
Kindly please help me and advice the code of wordwrap
also advise me the code of find, find next, replace and goto.
Posted
Comments
Sergey Alexandrovich Kryukov 25-Apr-14 7:44am    
"Notepad" is already created; I have no idea what are you creating, probably a text editor... :-)
Is it System.Windows.Forms, or what?
What you are doing looks correct. Use the debugger to see if the property really becomes true.
Never use names like richTextBox1, always rename auto-generated names as you use them.
—SA

1 solution

We can't tell you what the problem is: particularly form that small a code fragment - it needs access to the code while it is running to work out why you are getting the exception.

The basic reason is simple: something is not set yet, and it contains null - but we can't tell exactly what.

So...run your application in the debugger and when the exception happens look at your code. The exception will be on a particular line - and that's the one that is demonstrating the error. So hover the mouse pointer over each item on the line in turn, looking for which one is null.
When you find it, you can then look back in your code to find out why it is null - but that will depend on what it is, and when the code is being executed. Have a go - the debugger is very powerful, but pretty simple to use if you start with the "Debug" menu and find out what you can do before looking for the buttons which do the same thing.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900