tabpage_click

dualshock03

Well-known member
Joined
Jan 28, 2007
Messages
105
Programming Experience
1-3
Im wondering how can i execute this code properly.. it seems i need to click the tabpage twice before my 'Save_Set_' button will take prompt or action..

my code:

VB.NET:
 Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click
        teleport_controller = 1 '<--- declared as integer
    End Sub
    Private Sub TabPage2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage2.Click
        teleport_controller = 2 '<--- declared as integer
    End Sub

 Private Sub [COLOR="red"]Save_Set_Click[/COLOR](ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save_Set.Click
        If teleport_controller = 1 Then
            ADD_SETTINGS()
        ElseIf teleport_controller = 2 Then
            DELETE_SETTINGS()
        Else
        End If
    End Sub
------------------------------------------------------------------------
 Public Sub ADD_SETTINGS()
        If no_input() = False Then
            con1.Open()
            Try
                SAVE_SETTINGS()
                clear_usertxtbox()
            Catch SQL_err As MySql.Data.MySqlClient.MySqlException
                'New_msgbox.Show()
                'New_msgbox.label_SQLerr.Text = SQL_err.Message
                MsgBox(SQL_err.Message)
                'My.Computer.Audio.Play(My.Resources.Windows_XP_Critical_Stop, AudioPlayMode.WaitToComplete)
                'Me.Enabled = False
                con1.Close()
                Exit Sub
            End Try
            MsgBox("New User has been added", MsgBoxStyle.Information)
            con1.Close()
            LIST_ALL_RECORDSAA()
        End If
    End Sub

    Public Sub DELETE_SETTINGS()
        Try
            If verify5_combadmin() = True Then
                DELETE_CHANGES1()
                MsgBox("All Selected Users are Terminated!!", MsgBoxStyle.Information)
                clear_deleteuser_combdelete()
            ElseIf verify4_txtadmin() = True Then
                DELETE_CHANGES()
                MsgBox("User is Terminated!!", MsgBoxStyle.Information)
                clear_deleteuser_combdelete()
            ElseIf no_delete() = True Then
                MsgBox("Input Proper Entries", MsgBoxStyle.Exclamation)
            Else
                MsgBox("Unacceptable entry")
                clear_deleteuser_combdelete()
                txt_del.Focus()
            End If

        Catch err1 As Exception
            MsgBox("No such entry in database to delete from..")
        End Try
    End Sub

tabpage1 and tabpage2 are under in tabcontrol1 control.. the problem here is when i select to this tabpages my save_set button doesnt execute for the code.. but if i click the tabpage again its working... i dont like this kind of action at all..
 
Clicking a tab on the TabControl is NOT clicking a TabPage. Those tabs at the top of the control are part of the tabControl, not part of the TabPages, so they will raise the Click event of the TabControl. You'd have to click the body of the page to raise a Click event on the TabPage. I think what you want is the SelectedIndexChanged event of the TabControl, which will be raised each time the user moves to a different page.
 
Back
Top