如何在tabcontrol vb.net上定位选项卡
Net,TabStrip控件 标签是左对齐或右对齐,上对齐或下对齐 我需要从选项卡控件顶部我自己的位置开始选项卡如何在tabcontrol vb.net上定位选项卡,vb.net,winforms,tabcontrol,Vb.net,Winforms,Tabcontrol,Net,TabStrip控件 标签是左对齐或右对齐,上对齐或下对齐 我需要从选项卡控件顶部我自己的位置开始选项卡 与Internet Explorer一样,选项卡开始于HTTP地址框之后,但它将覆盖整个页面并在左侧对齐=0。要显示右对齐的选项卡 将选项卡控件添加到窗体中 将“路线”属性设置为“右侧” 将SizeMode属性设置为Fixed,以便所有选项卡的宽度相同 将ItemSize属性设置为选项卡的首选固定大小。请记住,ItemSize属性的行为就像选项卡位于顶部一样,尽管它们是右对齐的。因此
与Internet Explorer一样,选项卡开始于HTTP地址框之后,但它将覆盖整个页面并在左侧对齐=0。要显示右对齐的选项卡
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));