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 to an object error in CommandStack

Thread ID:





7272 Sep 17,2003 08:27 PM Sep 18,2003 01:53 AM Windows Forms 1
Tags: GridControl
Sue Harris
Asked On September 17, 2003 08:27 PM

Hi, I've got an class which inherits from GridControl. In one of the properties, which is getting called during initialisation, I call CommandStack.Clear(), and it throws an "Object reference not set to an object" error (CommandStack itself is not null). If I do a quick watch on the object before the call, it doesn't throw this exception, so I assume the problem is due to some object which gets created by a property get. Could you please tell me what I need to do to fix this problem. Thanks, Sue

Administrator [Syncfusion]
Replied On September 18, 2003 01:53 AM

Clear calls: undoStack.Clear(); redoStack.Clear(); So, these objects must not have been created at the point you are trying to call Clear. You can force their creation by just referencing their public property analogs, as they are created on demand as your access the public properties, UndoStack and RedoStack. So, this code may work.
if(CommandStack.UndoStack.Count > 0 || 
           CommandStack.RedoStack.Count > 0)


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.