System.ComponentModel.Design.MenuCommand.ToString C# (CSharp) Method

ToString() public method

public ToString ( ) : string
return string
        public override string ToString() {
            string str = commandID.ToString() + " : ";
            if ((status & SUPPORTED) != 0) {
                str += "Supported";
            }
            if ((status & ENABLED) != 0) {
                str += "|Enabled";
            }
            if ((status & INVISIBLE) == 0) {
                str += "|Visible";
            }
            if ((status & CHECKED) != 0) {
                str += "|Checked";
            }
            return str;
        }
    }

Usage Example

        /// <summary>
        ///  Adds a menu command to the document.  The menu command must already exist
        ///  on a menu; this merely adds a handler for it.
        /// </summary>
        public virtual void AddCommand(MenuCommand command)
        {
            ArgumentNullException.ThrowIfNull(command);

            // If the command already exists, it is an error to add
            // a duplicate.
            //
            if (((IMenuCommandService)this).FindCommand(command.CommandID) is not null)
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.MenuCommandService_DuplicateCommand, command.CommandID.ToString()));
            }

            ArrayList commandsList;

            lock (_commandGroupsLock)
            {
                if (!_commandGroups.TryGetValue(command.CommandID.Guid, out commandsList))
                {
                    commandsList = new ArrayList();
                    commandsList.Add(command);
                    _commandGroups.Add(command.CommandID.Guid, commandsList);
                }
                else
                {
                    commandsList.Add(command);
                }
            }

            command.CommandChanged += _commandChangedHandler;
            Debug.WriteLineIf(MENUSERVICE.TraceVerbose, "Command added: " + command.ToString());

            // raise event
            OnCommandsChanged(new MenuCommandsChangedEventArgs(MenuCommandsChangedType.CommandAdded, command));
        }
All Usage Examples Of System.ComponentModel.Design.MenuCommand::ToString