Exemple #1
0
        private void UpdateToolboxItem(IDesignerHost host)
        {
            if (host == null)
            {
                throw new ArgumentNullException();
            }
            // Now get a hold of the toolbox service and add an icon for our user control.  The
            // toolbox service will automatically maintain this icon as long as our file lives.
            //
            IToolboxService tbx = (IToolboxService)GetService(typeof(IToolboxService));

            if (tbx != null)
            {
                fullClassName = host.RootComponentClassName;
                if (this.toolboxItem != null)
                {
                    tbx.RemoveToolboxItem(this.toolboxItem);
                }
                this.toolboxItem = new UserControlToolboxItem(fullClassName);

                try {
                    tbx.AddLinkedToolboxItem(toolboxItem, SR.GetString(SR.UserControlTab), host);
                }
                catch (Exception ex) {
                    Debug.Fail("Failed to add toolbox item", ex.ToString());
                }
            }
        }