Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#4.0
Hello Team,
I have DataReader in which Names of ToolStripMenuItem has been stored.
I want to Disable all the ToolStripMenuItem which are in this DataReader.
I have below code -
                menuStrip1.Items[dr[0].ToString()].Visible = false;

But I am getting error as "object reference is not set to an instance of an object"
Please help.
Posted 18-Feb-13 6:12am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Object reference not set to an instance of an object

This error happens when you try to use a property or call a method of an object that is null. More details: here[^]

A simple use of Visual studio DEBUGGER can tell you the object because of which it is happening. Just look at the stack trace and put a debugger on that line. Check the objects of that line and see if any one is null and you are trying to use that objects property. Handle the same.
Maciej Los at 18-Feb-13 11:38am
Short and to the point. +5!
Sandeep Mewara at 18-Feb-13 11:44am
Thanks Maciej.
OT, do you have any interest on front end side? page designing - HTML?
Pravinkarne.31 at 20-Feb-13 9:44am
Thank you so much Friends!!!
You are just rocking!!!

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

  Print Answers RSS
0 Peter Leow 375
1 Sergey Alexandrovich Kryukov 330
2 Zoltán Zörgő 258
3 CHill60 195
4 TheRealSteveJudge 180
0 Sergey Alexandrovich Kryukov 8,853
1 OriginalGriff 6,631
2 Peter Leow 4,102
3 Zoltán Zörgő 3,714
4 Kornfeld Eliyahu Peter 2,525

Advertise | Privacy | Mobile
Web02 | 2.8.150123.1 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100