Click here to Skip to main content
15,897,291 members
Please Sign up or sign in to vote.
4.43/5 (5 votes)
See more:
Hi there,

Is there a way to have the TabControl on a WinForm without showing the Tab header?

Kind regards,
Jr
Posted
Comments
Member 10331652 12-Oct-13 3:22am    
;

Try that derived class form TabControl. It simply overrides the DisplayRectangle and adds a ShowTab Property for your new TabControl class. Does it help you ?


<br />public class MyTabControl : TabControl<br />    {<br />        public override Rectangle DisplayRectangle<br />        {<br />            get<br />            {<br />                if (showTabs)<br />                {<br />                    return base.DisplayRectangle;<br />                }<br />                else<br />                {<br />                    return new Rectangle(0, 0, Width, Height);<br />                }<br />            }<br />        }<br /><br />        #region Properties<br />        private bool showTabs = true;<br />        [Category("Apparence"),<br />        Description("Indique si les onglets s'affichent."),<br />        DefaultValue(true)]<br />        public bool ShowTabs<br />        {<br />            get { return showTabs; }<br />            set<br />            {<br />                showTabs = value;<br />                RecreateHandle();<br />            }<br />        }<br />        #endregion<br />    }<br /><br />
 
Share this answer
 
C#
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace Marketing_Tool
{

    class StackPanel : TabControl
    {
        protected override void WndProc(ref Message m)
        {
            // Hide tabs by trapping the TCM_ADJUSTRECT message
            if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1;
            else base.WndProc(ref m);
        }
    }
}
 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900