This question is locked. New answers and comments are not allowed.
Hi Guys,
I have a bit of an issue. When my user switches tabs I run a lengthly process, but this process only needs to be run coming from one specific tab. So... How do I identify what was the last selected tab?
Example:
----------------------------
Tab 1 Tab2 Tab3
On click of Tab2 from Tab1 I run process XYZ. On click of Tab2 from Tab3 I want to bypass process XYZ. When the user clicks on Tab2 how do I know the previous selected tab?
Many thanks,
~Mike
I have a bit of an issue. When my user switches tabs I run a lengthly process, but this process only needs to be run coming from one specific tab. So... How do I identify what was the last selected tab?
Example:
----------------------------
Tab 1 Tab2 Tab3
On click of Tab2 from Tab1 I run process XYZ. On click of Tab2 from Tab3 I want to bypass process XYZ. When the user clicks on Tab2 how do I know the previous selected tab?
Many thanks,
~Mike
5 Answers, 1 is accepted
0
Accepted
Hello Mike,
Thanks for writing.
I have prepared a sample project which demonstrates a possible way to implement the desired behavior. The idea is to save the last active tab in a variable and check this variable each time a new tab is selected. If the variable contains the tab in question, then you perform your action.
Note that in the constructor of my form I am initializing the lastSelectedTab variable with the initially selected TabItem in order not to brake the approach.
I hope this will help you.
Do not hesitate to write back if you need further assistance.
Kind regards,
Deyan
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thanks for writing.
I have prepared a sample project which demonstrates a possible way to implement the desired behavior. The idea is to save the last active tab in a variable and check this variable each time a new tab is selected. If the variable contains the tab in question, then you perform your action.
Note that in the constructor of my form I am initializing the lastSelectedTab variable with the initially selected TabItem in order not to brake the approach.
I hope this will help you.
Do not hesitate to write back if you need further assistance.
Kind regards,
Deyan
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike
Top achievements
Rank 2
answered on 08 Jan 2009, 04:17 PM
Sure, that is one way to do it, but I hoping you had something built-in I was missing.
Might be a nice little feature to add - I'm sure it wouldn't be all that hard. :)
Thanks for taking the time to write a sample.
~Mike
Might be a nice little feature to add - I'm sure it wouldn't be all that hard. :)
Thanks for taking the time to write a sample.
~Mike
0
Hi Mike,
In fact, I have researched your question a bit more and found another, easier way to get the last selected tab after a new one has been selected.
You can use the TabSelecting event which provides you with a reference to the tab that is going to be selected. At this point, the RadTabStrip.SelectedTab points to the currently selected tab in the control and TabCancelEventArgs.TabItem points to the tab that is going to be selected. Consider the code snippet below:
Sincerely yours,
Deyan
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
In fact, I have researched your question a bit more and found another, easier way to get the last selected tab after a new one has been selected.
You can use the TabSelecting event which provides you with a reference to the tab that is going to be selected. At this point, the RadTabStrip.SelectedTab points to the currently selected tab in the control and TabCancelEventArgs.TabItem points to the tab that is going to be selected. Consider the code snippet below:
private void On_TabSelecting(object sender, TabCancelEventArgs args) |
{ |
//this.radTabStrip1.SelectedTab contains the currently selected tab |
TabItem item = this.radTabStrip1.SelectedTab as TabItem; |
if (item != null && item.Text == "<NameOfTab>") |
{ |
//Trigger lenghty action |
} |
} |
Sincerely yours,
Deyan
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Andrea Licitra
Top achievements
Rank 1
answered on 04 Nov 2009, 06:35 PM
Hi!
I'm Italian and I'm new here, so please my bad english! :)
I tried this code posted by Telerik Admin, converted to VB, because I develop applications in Visual Basic 2005 .NET:
I'd like to implement this, when the users click the RadElement placed on each tab, that is a Close Button (made through Telerik Demos).
In fact, if I normally close one tab and use "Me.RadTabStrip1.SelectLastVisibleItem()", it selects the first tab...
Any ideas to fix this?
Thanks in advance, Andrea.
I'm Italian and I'm new here, so please my bad english! :)
I tried this code posted by Telerik Admin, converted to VB, because I develop applications in Visual Basic 2005 .NET:
Private Sub On_TabSelecting(sender As Object, args As TabCancelEventArgs) |
'this.radTabStrip1.SelectedTab contains the currently selected tab |
Dim item As TabItem = TryCast(Me.radTabStrip1.SelectedTab, TabItem) |
'Trigger lenghty action |
If item <> Nothing AndAlso item.Text = "<NameOfTab>" Then |
End If |
End Sub |
I'd like to implement this, when the users click the RadElement placed on each tab, that is a Close Button (made through Telerik Demos).
In fact, if I normally close one tab and use "Me.RadTabStrip1.SelectLastVisibleItem()", it selects the first tab...
Any ideas to fix this?
Thanks in advance, Andrea.
0
Hello Andrea,
I am not quite sure that I understand the behavior that you would like to implement? Could you please share some more details so that I can provide further help? Thanks for your time.
Sincerely yours,
Deyan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I am not quite sure that I understand the behavior that you would like to implement? Could you please share some more details so that I can provide further help? Thanks for your time.
Sincerely yours,
Deyan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.