Click here to Skip to main content
15,896,539 members
Articles / Programming Languages / C#

NeoTabControl Library

Rate me:
Please Sign up or sign in to vote.
4.96/5 (110 votes)
28 Sep 2012CPOL16 min read 200.6K   21.3K   163  
A custom .NET tab control for WinForms applications with add-in renderer support.
using System;
using System.ComponentModel;
using System.Windows.Forms.Design;
using System.Security.Permissions;
using System.ComponentModel.Design;

namespace NeoTabControlLibrary.Design
{
    [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
    public class NeoTabPageDesigner : ScrollableControlDesigner
    {
        #region Instance Members

        #endregion

        #region Constructor

        public NeoTabPageDesigner()
            : base() { }

        #endregion

        #region Destructor

        ~NeoTabPageDesigner()
        {
            GC.SuppressFinalize(this);
        }

        #endregion

        #region Property

        public override SelectionRules SelectionRules
        {
            get
            {
                /* The component is locked to its container. This prevents moving 
                   and sizing, even if you’ve specified those flags. */
                return SelectionRules.Locked;
            }
        }        
        
        #endregion

        #region Override Methods

        /*  As a general rule, always call the base method first in the PreFilterXxx() methods and last in the 
            PostFilterXxx() methods. This way, all designer classes are given the proper opportunity to apply their 
            changes. The ControlDesigner and ComponentDesigner use these methods to add properties like Visible, 
            Enabled, Name, and Locked. */

        /// <summary>
        /// Override this method to remove unused or inappropriate events.
        /// </summary>
        /// <param name="events">Events collection of the control.</param>
        protected override void PostFilterEvents(System.Collections.IDictionary events)
        {
            events.Remove("DockChanged");
            events.Remove("MarginChanged");
            events.Remove("VisibleChanged");
            events.Remove("EnabledChanged");
            events.Remove("TabStopChanged");
            events.Remove("TabIndexChanged");
            events.Remove("LocationChanged");

            base.PostFilterEvents(events);
        }

        /// <summary>
        /// Override this method to remove unused or inappropriate properties.
        /// </summary>
        /// <param name="properties">Properties collection of the control.</param>
        protected override void PostFilterProperties(System.Collections.IDictionary properties)
        {
            properties.Remove("Size");
            properties.Remove("Dock");
            properties.Remove("Margin");
            properties.Remove("Anchor");
            properties.Remove("Visible");
            properties.Remove("Enabled");
            properties.Remove("TabStop");
            properties.Remove("TabIndex");
            properties.Remove("Location");
            properties.Remove("BorderStyle");
            properties.Remove("MaximumSize");
            properties.Remove("MinimumSize");

            base.PostFilterProperties(properties);
        }
        
        public override bool CanBeParentedTo(IDesigner parentDesigner)
        {
            // Control can only be parented by NeoTabWindow. 
            return (parentDesigner is NeoTabWindowDesigner);
        }

        #endregion

        #region Helper Methods

        #endregion

        #region General Methods

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer (Senior) ARELTEK
Turkey Turkey
Since 1998...

MCPD - Enterprise Application Developer

“Hesaplı hareket ettiğini zanneden ve onunla iftihar eyliyen dar kafalar; kurtulmağa, yükselmeğe elverişli hiç bir eser vücüda getirmezler. Kurtuluş ve yükselişi, ancak varlığına dayanan ve mülkü milletin gizli kapalı hazinelerini verimli hale getirmesini bilen, şahsi menfaatini millet menfaati uğruna feda eden, ruhu idealist, dimağı realist şahsiyetlerde aramalıdır.”

Nuri Demirağ, 1947

Comments and Discussions