日本好好热aⅴ|国产99视频精品免费观看|日本成人aV在线|久热香蕉国产在线

  • <cite id="ikgdy"><table id="ikgdy"></table></cite>
    1. 西西軟件園多重安全檢測下載網(wǎng)站、值得信賴的軟件下載站!
      軟件
      軟件
      文章
      搜索

      首頁編程開發(fā)其它知識 → 去掉TabControl控件默認添加的TabPage兩種解決方案

      去掉TabControl控件默認添加的TabPage兩種解決方案

      相關(guān)軟件相關(guān)文章發(fā)表評論 來源:本站整理時間:2010/8/24 0:21:03字體大。A-A+

      作者:佚名點擊:95次評論:0次標簽: 控件 tab

      • 類型:遠程監(jiān)控大。4.6M語言:中文 評分:5.7
      • 標簽:
      立即下載

      把TabControl添加到設(shè)計器的時候,默認會添加兩個TabPage,當繼承TabControl自定義控件的時候,這兩個默認的TabPage常常會制造一些麻煩,今天我來介紹一種方法來去掉這兩個默認的TabPage:
      實際上思路比較簡單,主要是通過ToolboxItem特性提供自定義的ToolboxItem類來修改工具箱中的控件的初始化工程,只需要繼承ToolboxItem類,重寫CreateComponentsCore方法就可以實現(xiàn)了:
      [ToolboxItem(typeof(DemoToolboxItem))]
      public class MyTabControl : TabControl
      {
      }


      [Serializable] //ToolboxItem必須是可序列化的
      class DemoToolboxItem : ToolboxItem
      {
      // The add components dialog in VS looks for a public
      // ctor that takes a type.
      public DemoToolboxItem(Type toolType)
      : base(toolType)
      {
      }

      // And you must provide this special constructor for serialization.
      // If you add additional data to MyToolboxItem that you
      // want to serialize, you may override Deserialize and
      // Serialize methods to add that data.
      DemoToolboxItem(SerializationInfo info, StreamingContext context)
      {
      Deserialize(info, context);
      }

      // This implementation sets the new control's Text and
      // AutoSize properties.
      protected override IComponent[] CreateComponentsCore(
      IDesignerHost host,
      IDictionary defaultValues)
      {

      IComponent[] comps = base.CreateComponentsCore(host, defaultValues);


      MessageBox.Show(((MyTabControl)comps[0]).TabPages.Count.ToString());
      ((MyTabControl)comps[0]).TabPages.RemoveAt(0);//去掉默認添加的TabPage
      ((MyTabControl)comps[0]).TabPages.RemoveAt(0);
      return comps;
      }
      }
      當然,如果愿意的話,也可以自己在CreateComponentsCore中添加自定義的TabPage來使我們的TabControl更加的有實用價值!

        相關(guān)評論

        閱讀本文后您有什么感想? 已有人給出評價!

        • 8 喜歡喜歡
        • 3 頂
        • 1 難過難過
        • 5 囧
        • 3 圍觀圍觀
        • 2 無聊無聊

        熱門評論

        最新評論

        發(fā)表評論 查看所有評論(0)

        昵稱:
        表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
        字數(shù): 0/500 (您的評論需要經(jīng)過審核才能顯示)