How to handle stacked controls in .NET Winforms?

前端 未结 1 1714
借酒劲吻你
借酒劲吻你 2021-01-06 08:57

I have a form that will multiple Panel controls stacked on top of each other, each one being shown/hidden based on other selected options on the form. This has been a real p

1条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-06 09:21

    You can hide the tabs, very convenient in the designer. Add a new class to your project and paste this code:

    using System;
    using System.Windows.Forms;
    
    public class TablessControl : 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);
      }
    }
    

    0 讨论(0)
提交回复
热议问题