4 Replies - 22494 Views - Last Post: 23 September 2011 - 09:11 AM Rate Topic: -----

#1 syncupsolutions  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 04-May 11

TabPages switch by button only

Posted 23 September 2011 - 12:24 AM

Is there a way I can allow the switching on the pages in my TabControl by the pressing of the appropriate button, which in this case is Button1, the Next button. Something I can add into the SelectedIndexChanged event of the control ?
Is This A Good Question/Topic? 0
  • +

Replies To: TabPages switch by button only

#2 DimitriV  Icon User is offline

  • vexing conundrum
  • member icon

Reputation: 587
  • View blog
  • Posts: 2,746
  • Joined: 24-July 11

Re: TabPages switch by button only

Posted 23 September 2011 - 02:34 AM

You could, for the next button, type:
TabControl1.SelectedIndex = TabControl1.SelectedIndex  + 1

Is that a bit like what you meant?

Also, each time you click that button it could update an Integer value, and in SelectedIndexChanged say
if myvalue = TabControl1.SelectedIndex then
'Do nothing
Else
TabControl1.SelectedIndex = myvalue


HTH
Was This Post Helpful? 1
  • +
  • -

#3 syncupsolutions  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 04-May 11

Re: TabPages switch by button only

Posted 23 September 2011 - 03:56 AM

No sir that wasn't what I was asking. Let me elaborate a little more. As you know, the tab control has multiple tab pages. The user, instead of using the next button, could simply click on the next tab. Skipping my try/catch methods for ensuring the values that are required are filled in. I could put similar protection in the selectedindexchanged event of the tab control, but it gets a little tricky. What I want is to ensure that the only way a user moves through the pages, is by the next button. In a sense, if the tab control's selected index changes by the button being pressed - let it change, 'else' stop the tab control from moving onto the next page.
Was This Post Helpful? 0
  • +
  • -

#4 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 225
  • View blog
  • Posts: 1,526
  • Joined: 16-March 11

Re: TabPages switch by button only

Posted 23 September 2011 - 07:41 AM

Maybe this is what you are talking about:
 Dim CountTab As Integer = 1
    Dim MaxTab As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Not CountTab = MaxTab Then
            TabControl1.SelectTab(CountTab)
            CountTab += 1
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        MaxTab = TabControl1.TabCount
    End Sub



Just place a barrier using the click events of your tab pages. :) I would suggest placing one single tab page, when they click to the next step, or successfully finish adding all the necessary information, have a timer, or a button ready to dynamically create a new tab page with controls, and events.

Maybe these links will help:
http://www.dreaminco...-between-forms/

http://www.dreaminco...ols-generation/

And last but not least my favorite:
http://www.dreaminco...snippet6195.htm

This post has been edited by trevster344: 23 September 2011 - 07:42 AM

Was This Post Helpful? 0
  • +
  • -

#5 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: TabPages switch by button only

Posted 23 September 2011 - 09:11 AM

If I understand you correctly:

Private cantchange As Boolean
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
    cantchange = False
    'if it's not the last page
    If Not TabControl1.SelectedIndex = TabControl1.Tabpages.Count -1 Then
      TabControl1.SelectedIndex += 1
    End If
    cantchange = True
End Sub

Private Sub TabControl1_Selecting(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles TabControl1.Selecting
    e.Cancel = cantchange
End Sub

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1