8 Replies - 22280 Views - Last Post: 06 September 2013 - 10:07 AM Rate Topic: -----

#1 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Adding a close button in a tabControl tabPages

Posted 10 June 2011 - 12:01 PM

Ok what I am working is creating a tabpage at run time, I ahve a class that inherits tabpage class and when I call, it creates a new tabpage and add it to the tabControl, My codes are as:
Class CreatenewTab : Inherits System.Windows.Forms.TabPage
'Some implementation here
end Class

and I created a new instance of it here:
Dim n As New CreatenewTab()
Form1.tabPage.TabPages.Add(n) 'tabPage is a tabControl present in Form1
n.getwebpage.Dock = DockStyle.Fill n.getwebpage.Parent = n
n.getwebpage.Show()
n.Text = n.getUrl
n.Show()
n.Select()
n.Focus()

This is a sub that creates a new tab, now I have two questions:
-How can I add a close button in every new tab as the one available in VS tabs or Mozilla?
- How to make a new created tab to be selected and top? I have tried .show(), .Select() and .Focus() but nothing happens. What I mean is when you click on add new Tab, like in Browser a new tab is created and is selected for use(become top)

Is This A Good Question/Topic? 0
  • +

Replies To: Adding a close button in a tabControl tabPages

#2 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 968
  • Joined: 09-May 09

Re: Adding a close button in a tabControl tabPages

Posted 10 June 2011 - 04:38 PM

i would also like to know this :)
Was This Post Helpful? 0
  • +
  • -

#3 Jeff H  Icon User is offline

  • D.I.C Regular

Reputation: 112
  • View blog
  • Posts: 308
  • Joined: 30-January 11

Re: Adding a close button in a tabControl tabPages

Posted 10 June 2011 - 05:08 PM

For making the new tab on top you can use the SelectedTab property of the TabControl.

Just assign the new TabPage to the property

        Dim tp As New TabPage
        TabCtrl.TabPages.Add(tp) ''''TabCtrl is the TabControl
        TabCtrl.SelectedTab = tp



Was This Post Helpful? 1
  • +
  • -

#4 Jeff H  Icon User is offline

  • D.I.C Regular

Reputation: 112
  • View blog
  • Posts: 308
  • Joined: 30-January 11

Re: Adding a close button in a tabControl tabPages

Posted 10 June 2011 - 05:18 PM

Here are some links for close button
http://stackoverflow...individual-tabs

http://www.codeproje...tabcontrol.aspx
Was This Post Helpful? 1
  • +
  • -

#5 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 183
  • View blog
  • Posts: 1,152
  • Joined: 10-December 08

Re: Adding a close button in a tabControl tabPages

Posted 10 June 2011 - 05:22 PM

I'd have to recommend looking at Thomas Maxwell's IE7 clone - it's got a great tabcontrol with close buttons & the possibility of images on the tabcontrol too.

This post has been edited by Jack Eagles1: 10 June 2011 - 05:22 PM

Was This Post Helpful? 1
  • +
  • -

#6 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Adding a close button in a tabControl tabPages

Posted 11 June 2011 - 11:20 AM

Ok thanks I got something useful to start. :)
@ Jack Eagles1: I got this if it is what you meant, thanks. If not please tell me for the link :D
Was This Post Helpful? 0
  • +
  • -

#7 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 183
  • View blog
  • Posts: 1,152
  • Joined: 10-December 08

Re: Adding a close button in a tabControl tabPages

Posted 11 June 2011 - 01:06 PM

That's it, but having just looked more closely at the project, the actual source of the tabcontrol isn't Thomas Maxwell's IE clone, it's here:


http://www.codeproje...TabControl.aspx
Was This Post Helpful? 1
  • +
  • -

#8 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Adding a close button in a tabControl tabPages

Posted 11 June 2011 - 01:12 PM

Thanks, it is the same idea of what I was trying to do, something like browser :)
Was This Post Helpful? 0
  • +
  • -

#9 Dej  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 06-September 13

Re: Adding a close button in a tabControl tabPages

Posted 06 September 2013 - 10:07 AM

You can check out this article, how to add close button to tab headers in TabControl is explained in details.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1