Jump to content

Click em TabPage


bigboy123
 Share

Recommended Posts

Boas a todos,

Tenho aqui um pequeno problema que gostaria de resolver com a vossa ajuda, é o seguinte :

Eu inseri no meu Form um TabControl com 4 TabPages.

Eu preciso que ao clicar na aba de uma TabPage apareça por exemplo " MsgBox("Teste") " , mas o problema é que com o evento Click da TabPage so aparece a mensgem se eu clicar na página do TabPage e não na aba !

Alguém sabe como posso resolver isto ?  😉

Link to comment
Share on other sites

Lembra-te que estás a trabalhar eventos da TabControl e não da TabPage.

O Click refere-se portanto ao TabControl. O que tens de verificar é se o índice de selecção da TabControl alterou e quando alterar significa que alguém carregou num tab diferente do actual.

Depois basta trabalhares com o "SelectedTab" que representa uma instância da classe TabPage, neste caso a que foi seleccionada.

    Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
        MsgBox("Sou a tab com o texto:" & TabControl1.SelectedTab.Text)
    End Sub

Sérgio Ribeiro


"Great coders aren't born. They're compiled and released"
"Expert coders do not need a keyboard. They just throw magnets at the RAM chips"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.