I've got a bunch of TabPages inside a TabControl; I'd like to have an easy way for the user to close individual tabs; kinda like IE or FireFox does with their tabs.
Can I do that using the default Windows Control, without too much work?
Printable View
I've got a bunch of TabPages inside a TabControl; I'd like to have an easy way for the user to close individual tabs; kinda like IE or FireFox does with their tabs.
Can I do that using the default Windows Control, without too much work?
Hi,
You can try something like this:
vb Code:
Imports System.Drawing Imports System.Windows.Forms Public Class Form1 Inherits Form Private tabControl1 As TabControl Private tabPage1 As TabPage Private button1 As Button Public Sub New() Me.tabControl1 = New TabControl() Me.tabPage1 = New TabPage() Me.button1 = New Button() Me.tabControl1.TabPages.Add(tabPage1) Me.tabControl1.Location = New Point(25, 25) Me.tabControl1.Size = New Size(250, 250) ' Gets the controls collection for tabPage1. ' Adds button1 to this collection. Me.tabPage1.Controls.Add(button1) Me.button1.Text = "button1" Me.button1.Location = New Point(25, 25) Me.ClientSize = New Size(300, 300) Me.Controls.Add(tabControl1) End Sub Shared Sub Main() Application.Run(New Form1()) End Sub End Class
Wkr,
sparrow1
Placing a button on the tabs of a TabControl is not the same thing as placing a Button control on each TabPage.
The tabs are actually part of the TabControl itself, not each TabPage. As such you would have to owner-draw the tabs and draw your own button.
http://www.vb-helper.com/howto_net_ownerdraw_tab.html
Great link, I found it very useful myself. Thanks :thumb: