Results 1 to 5 of 5

Thread: Tab control click event

  1. #1

    Thread Starter
    PowerPoster SuperSparks's Avatar
    Join Date
    May 2003
    Location
    London, England
    Posts
    265

    Tab control click event

    This should be a simple enough thing to do:

    VB Code:
    1. Private Sub tabClock_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles tabClock.Click
    2.  
    3.         tmrOne.Enabled = True       ' start main clock timer
    4. ' more code to go here
    5.  
    6.  
    7.     End Sub             ' tabClock_Click

    All I want to do is to start the timer when a particular tab is clicked, but the timer never starts. I put a breakpoint in the first line of code and the break never happens, which suggests that the click event is being completely ignored.

    I've hunted high and low in MSDN Library for what's going on, to no avail. Have any of you guys got any ideas?
    Nick.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    One way
    VB Code:
    1. Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
    2.  
    3.         If Me.TabControl1.SelectedIndex = 0 Then
    4.             MsgBox("you clicked TabPage1")
    5.         End If
    6.     End Sub

  3. #3

    Thread Starter
    PowerPoster SuperSparks's Avatar
    Join Date
    May 2003
    Location
    London, England
    Posts
    265
    Thanks Pirate,

    That does work, though it also has the annoying side effect of executing that code when the app is started. I expect I can work round that if I have to.

    I'm still curious as to why the Click event doesn't work, though. Is it a bug or do I need to do something else to make it work?
    Nick.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    This will work , I mean it won't show anything unless the tabpage is completely shown .

    VB Code:
    1. Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
    2.         Dim indx As Integer = Me.TabControl1.SelectedIndex
    3.         If indx = 0 AndAlso Me.TabControl1.TabPages(indx).Focus = True Then
    4.             MsgBox("blah")
    5.         End If
    6.     End Sub

  5. #5

    Thread Starter
    PowerPoster SuperSparks's Avatar
    Join Date
    May 2003
    Location
    London, England
    Posts
    265
    Excellent, that'll do nicely

    Thanks again Pirate.
    Nick.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width