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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Object reference not set to an object error in CommandStack

Thread ID:





7272 Sep 18,2003 12:27 AM UTC Sep 18,2003 05:53 AM UTC WinForms 1
Tags: GridControl
Sue Harris
Asked On September 18, 2003 12:27 AM UTC

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 05:53 AM UTC

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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon