如何编写最初没有标签的继承的标签控件 [英] How do I write an inherited tab control that initially has no tabs

查看:82
本文介绍了如何编写最初没有标签的继承的标签控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有个问题.我整天都在搜索google,但运气不好,试图找出如何创建一个最初没有标签页的继承的标签控件.我的意思是:控件的设计方式是程序员必须调用带有参数的内置方法,并且该方法将相应地填写选项卡页.现在,tabcontrol具有此烦人的功能,当我将控件拖放到窗体上时,它会在窗体设计器中自动生成以下内容:

Hello everyone,

I have a problem. I''ve been searching google all day with no luck trying to find out how do I create an inherited tab control that initially has no tab pages. Here''s what I mean: the control is being designed in a way that the programmer has to call a built in method with a parameter, and that method will fill out the tabpage accordingly. Right now, tabcontrol has this annoying feature that when I drag and drop the control on a form, it automatically generates the following in the form designer:

'
'MyControl
'
Me.MyControl.Controls.Add(Me.TabPage1)
Me.MyControl.Controls.Add(Me.TabPage2)
Me.MyControl.Location = New System.Drawing.Point(0, 0)
Me.MyControl.Name = "MyControl"
Me.MyControl.SelectedIndex = 0
Me.MyControl.Size = New System.Drawing.Size(496, 462)
Me.MyControl.TabIndex = 0
'
'TabPage1
'
Me.TabPage1.Location = New System.Drawing.Point(4, 22)
Me.TabPage1.Name = "TabPage1"
Me.TabPage1.Padding = New System.Windows.Forms.Padding(3)
Me.TabPage1.Size = New System.Drawing.Size(488, 436)
Me.TabPage1.TabIndex = 0
Me.TabPage1.Text = "TabPage1"
Me.TabPage1.UseVisualStyleBackColor = True
'
'TabPage2
'
Me.TabPage2.Location = New System.Drawing.Point(4, 22)
Me.TabPage2.Name = "TabPage2"
Me.TabPage2.Padding = New System.Windows.Forms.Padding(3)
Me.TabPage2.Size = New System.Drawing.Size(488, 436)
Me.TabPage2.TabIndex = 1
Me.TabPage2.Text = "TabPage2"
Me.TabPage2.UseVisualStyleBackColor = True



这对我来说完全没有用...我想防止每次拖放控件时都生成上述代码...请帮助!



Which is totally useless to me... I want to prevent the above code from being generated whenever I drag and drop my control... Please help!

推荐答案

编辑TabPages属性并删除页面.
Edit the TabPages property and delete the pages.


谁强迫您使用Designer?添加一个空的TabControl,并且不添加任何内容.删除所有创建选项卡页的代码,以便在运行时以零个选项卡页开始.顺便说一句,如果您对使用此控件感到困惑,那么自动生成的代码对您也不是无用的:您可以查看它以了解如何在代码中添加制表符.

—SA
Who forces you to use the Designer? Add an empty TabControl, and don''t add anything to it. Remove all code creating a tab page, so you would start with zero tab pages during run-time. By the way, if you are confused about using of this control, the auto-generated code is not useless to you: you can look at it to understand how to add tabs in your code.

—SA


我认为我偶然发现了解决方案.

http://bytes.com/topic/c-sharp/answers/576709-adding-custom-tabpages-design-time [ ^ ]
I think I''ve stumbled upon the solution.

http://bytes.com/topic/c-sharp/answers/576709-adding-custom-tabpages-design-time[^]


这篇关于如何编写最初没有标签的继承的标签控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆