0
VB.Net,TabStrip控件,如何定位在一个TabControl vb.net标签
标签是左对齐或右和顶部或底部
我需要从我自己的位置在最前面的开始选项卡Tab控件
与Internet Explorer类似,选项卡在HTTP地址框之后开始,但它将覆盖整页和左对齐= 0。
VB.Net,TabStrip控件,如何定位在一个TabControl vb.net标签
标签是左对齐或右和顶部或底部
我需要从我自己的位置在最前面的开始选项卡Tab控件
与Internet Explorer类似,选项卡在HTTP地址框之后开始,但它将覆盖整页和左对齐= 0。
要显示右对齐的标签
一个的TabControl添加到您的窗体。
设置对齐属性为对。
设置SizeMode属性固定,让所有标签都是相同的宽度。
将项目大小属性设置为选项卡的首选固定大小。请记住ItemSize属性的行为与标签在顶部一样,尽管它们是右对齐的。因此,为了使选项卡变宽,您必须更改高度属性,并且为了使它们更高,您必须更改宽度属性。
在下面的代码示例,宽度设置为25和高度被设定为150
设置DrawMode属性OwnerDrawFixed。
定义处理为DrawItem事件TabControl的呈现由左到右的文本。
C#
public Form1()
{
// Remove this call if you do not program using Visual Studio.
InitializeComponent();
tabControl1.DrawItem += new DrawItemEventHandler(tabControl1_DrawItem);
}
private void tabControl1_DrawItem(Object sender, System.Windows.Forms.DrawItemEventArgs e)
{
Graphics g = e.Graphics;
Brush _textBrush;
// Get the item from the collection.
TabPage _tabPage = tabControl1.TabPages[e.Index];
// Get the real bounds for the tab rectangle.
Rectangle _tabBounds = tabControl1.GetTabRect(e.Index);
if (e.State == DrawItemState.Selected)
{
// Draw a different background color, and don't paint a focus rectangle.
_textBrush = new SolidBrush(Color.Red);
g.FillRectangle(Brushes.Gray, e.Bounds);
}
else
{
_textBrush = new System.Drawing.SolidBrush(e.ForeColor);
e.DrawBackground();
}
// Use our own font.
Font _tabFont = new Font("Arial", (float)10.0, FontStyle.Bold, GraphicsUnit.Pixel);
// Draw string. Center the text.
StringFormat _stringFlags = new StringFormat();
_stringFlags.Alignment = StringAlignment.Center;
_stringFlags.LineAlignment = StringAlignment.Center;
g.DrawString(_tabPage.Text, _tabFont, _textBrush, _tabBounds, new StringFormat(_stringFlags));
Hmya,而Internet Explorer *不*使用一个TabControl,它的标签是完全自定义绘制。您可以通过不使用标签页来模拟类似的东西,只需使TabControl的高度足以显示标签即可。 –