Solved

Hi Apncealbuerne,

Posted on 2009-05-06
9
223 Views
Last Modified: 2013-11-26
I am trying to do same for a leave event of tab page, but there is no such e.Cancel method available.
Please guide me, actually i am trying to prompt a user if he want to navigate away from current tab page or not if user selects No then Leave event must get cancel and user must remains on the same tab page.

Please guide.
Thanks in Advance.
0
Comment
Question by:ArunVashist
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 15

Assisted Solution

by:JackOfPH
JackOfPH earned 150 total points
ID: 24321550
Use the Selecting event of the tab...

In vb the code is something like this


Private Sub TabControl1_Selecting(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles TabControl1.Selecting
If msgbox("Do you want to move to other page?", vbyesno) = vbyes then        
e.Cancel = True
End Sub

Open in new window

0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24321556
Selecting event will trigger before the tab was moved so you can use it.
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24321562
Use the Selecting event of the tab instead of leave event.
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 15

Expert Comment

by:JackOfPH
ID: 24321578
I hope you  get the idea...

Jack

The code is something like the one posted below...


Private Sub TabControl1_Selecting(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles TabControl1.Selecting
        If MessageBox.Show("Do you want to move to other page?", "Testing", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then
            e.Cancel = True
        End If
    End Sub

Open in new window

0
 

Author Comment

by:ArunVashist
ID: 24321647
Hi JackOfPH,

the suggested "Selecting" event works fine, but the Issue is with leave event only, actually user can also leave the Tab Page by selecting some other option from Menu in that case current Tab control is hidden and requested Tab control appears. now I am managing the "Visiblechanged" event to get the current SelectedIndex of TabControl and accordingly fill the controls.

Now what i exactly need is a Prompt when user switch to other Tab page in same Tab control or  when user switch to other Tab Control.

Thanks in advance,
Arun Vashist
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24321768
okey, why don't you put the checking everytime you are prompted to created the tab?


Private Sub ViewTabpage(ByVal TabName As String, ByVal myControls As BaseClass.BaseModule)
       
         If MessageBox.Show("Do you want to move to other page?", "Testing", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                   
        Dim objTabpage As New TabPage

        objTabpage.Name = TabName
        objTabpage.Text = TabName
     
        TabControl1.Controls.Add(objTabpage)
else
   'Do staff if user decide to stay in the tab...
       End IF
End Sub
0
 

Author Comment

by:ArunVashist
ID: 24321824
Hey JackOfPH,

I am not adding and removing tabs programmatically, actually all tab controls and respective tab pages are pre-designed, we just hide and show the tab controls according to option selected by user from menu.

So we need two prompts one when tab control leaves focus or hide and second when user switches between tap pages.

thanks,
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24321848
Can you show me on how you hide the tab?
A sample code may help you explain better my point...
0
 

Accepted Solution

by:
ArunVashist earned 0 total points
ID: 24354588
Well Friends,

i manage to fix this issue on my own, now i am managing two events to show alert/prompt on tab page change and tab control change. Actually i was in serious need to close this issue so i know its not that practical but it works for me.

thanks,
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# Windows Form Navigation - Total Beginner 9 89
C# DataTable (in memory) vs SQL Lookups 4 67
Return array 3 32
GET INFO ABOUT WHAT THE PRINTER IS DOING ? 11 69
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question