To Navigate Tabs by Index
Use this board to post your code snippets - tips and tricks
7 posts
Page 1 of 1
I want to share my little Snips on Tab Navigating by index.
This is how it works.
When the previous button reaches the first tab which is the 0 index and you will click the button again the button Enabled property will become False. The same thing will do if the Tab reaches the last index it will also set the tab Enables property to false.
But if you ckick any Tab with the mouse except the first and the last Tab all buttons will be enabled.
Here are the codes:
This is how it works.
When the previous button reaches the first tab which is the 0 index and you will click the button again the button Enabled property will become False. The same thing will do if the Tab reaches the last index it will also set the tab Enables property to false.
But if you ckick any Tab with the mouse except the first and the last Tab all buttons will be enabled.
Here are the codes:
Code: Select all
I hope you like this...Thanks.
Public Class Tabform
Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles btnPrevious.Click
If tabExample.SelectedIndex = 0 Then
btnPrevious.Enabled = False
Else
tabExample.SelectTab(tabExample.SelectedIndex - 1)
btnNext.Enabled = True
End If
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles btnNext.Click
If tabExample.SelectedIndex = tabExample.TabCount - 1 Then
btnNext.Enabled = False
Else
tabExample.SelectTab(tabExample.SelectedIndex + 1)
btnPrevious.Enabled = True
End If
End Sub
Private Sub tabExample_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles tabExample.MouseClick
btnNext.Enabled = True
btnPrevious.Enabled = True
End Sub
End Class
You do not have the required permissions to view the files attached to this post.
Dude there is no indexers for the SelectedTab property, so this wont work at all.
Instead of
Instead of
Code: Select all
use tabExample.SelectTab(tabExample.SelectedIndex + 1)
Code: Select all
or tabExample.SelectTab = tabExample.TabPages(tabExample.SelectedIndex + 1)
Code: Select all
tabExample.SelectedIndex += 1
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

The code worked for me, but the next/previous buttons needed an extra click to be disabled when they already should be.
You could fix that with this code:
You could fix that with this code:
Code: Select all
Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
tabExample.SelectedIndex -= 1
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
tabExample.SelectedIndex += 1
End Sub
Private Sub tabExample_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tabExample.SelectedIndexChanged
btnNext.Enabled = Not (tabExample.SelectedIndex = (tabExample.TabCount - 1))
btnPrevious.Enabled = Not (tabExample.SelectedIndex = 0)
End Sub
mandai wrote:The code worked for me, but the next/previous buttons needed an extra click to be disabled when they already should be.Excellent mandai the Tab control now works what I really want to happen. Thank you very very very much you're smart. wahooo; wahooo; clapper; clapper; cooll; cooll;
You could fix that with this code:Code: Select allPrivate Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click tabExample.SelectedIndex -= 1 End Sub Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click tabExample.SelectedIndex += 1 End Sub Private Sub tabExample_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tabExample.SelectedIndexChanged btnNext.Enabled = Not (tabExample.SelectedIndex = (tabExample.TabCount - 1)) btnPrevious.Enabled = Not (tabExample.SelectedIndex = 0) End Sub
RonaldHarvey wrote:Thanks Axel i will try. cooll;ffs I AM AXEL :P
Axel wrote:Axel sorry it was supposed to be MrAksel and not Axel in my first post the yellow colored MrAksel confused my eyes too much a sign of my old age.RonaldHarvey wrote:Thanks Axel i will try. cooll;ffs I AM AXEL :P
Thanks for reminding friend. :o
7 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023