Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. TabControl.SelectionChanged

TabControl.SelectionChanged

Scheduled Pinned Locked Moved WCF and WF
tutorialquestion
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yanairon
    wrote on last edited by
    #1

    HI i"m trying to make a simple task when a tab is changing in a tab control, i want to check if a save should be done. and if so - ask the user if he wants to save or stay in the same tab (keep editing for example) i can't cancel the tab selection in the SelectionChanged event what can i do? Thanks, Yanai

    L 1 Reply Last reply
    0
    • Y yanairon

      HI i"m trying to make a simple task when a tab is changing in a tab control, i want to check if a save should be done. and if so - ask the user if he wants to save or stay in the same tab (keep editing for example) i can't cancel the tab selection in the SelectionChanged event what can i do? Thanks, Yanai

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Yanai, Just handle the PreviewMouseLeftButtonDown event for the TabControl. Then check if the Source of the RoutedEvent is a TabItem. Perform your testing to see if you want to cancel the event and if so use, e.Handled = True to handle the event which will cancel the tab page switching.

      Private Sub tcPages_PreviewMouseLeftButtonDown(ByVal sender As Object, _
      ByVal e As System.Windows.Input.MouseButtonEventArgs) _
      Handles tcPages.PreviewMouseLeftButtonDown

      If TypeOf e.Source Is TabItem Then
          'perform your test here
      
          'if you want to keep editing then use this code
          e.Handled = True
      
      End If
      

      End Sub

      Cheers, Karl » CodeProject 2008 MVP » Microsoft MVP - Client App Dev My Blog | Mole's Home Page | MVP Profile

      Just a grain of sand on the worlds beaches.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups