This is a migrated thread and some comments may be shown as answers.
Events not working?
8 Answers 122 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daniel Plomp
Top achievements
Rank 2
Daniel Plomp asked on 30 Nov 2006, 11:55 AM
Hello all,

When swich from one tab item to another tab item I was expecting that the event 'TabIndex_Changed' or 'TabPostition_Changed' was fired. But nothing happened.

How can I check if a user is changing from one tab to another?

Thanks,
Daniel

8 Answers, 1 is accepted

Sort by
0
Chris
Telerik team
answered on 30 Nov 2006, 02:00 PM
Hi Daniel,

The TabsPositionChanged event is fired when the TabPosition property changes. The TabPosition property defines the position of the tab items relatively to the base area. The TabIndexChanged event is fired when the TabIndex property changes and basically every WinForms control has this property and this event. The TabIndex property is used to get or set the tab order of the respective control, so when you click the TAB key the focus changes from one control to another.
The event which you should use is named TabSelected. It is fired when a tab is selected either by clicking on it or programmatically using the API.
I hope this information helps.

Greetings,
Chris
the telerik team

0
Mukunda Manoj
Top achievements
Rank 1
answered on 30 Nov 2006, 02:06 PM
There is a click event on tab, which fires when a tab is clicked.
0
Daniel Plomp
Top achievements
Rank 2
answered on 30 Nov 2006, 02:53 PM
Okay, I also found out that 'TabSelected' is the event I need. But... I was expecting that the 'Telerik.WinControls.UI.TabEventArgs args' would contain the information about the tab that was currently selected.

But e.g. the .name property has a value of "".
So, is there a SelectedIndex property or something which will let me readout the index of the selected tab?

I should read the manual first I guess, but most of the time using the telerik suite, it is pretty straight forward.

Allthough I couldn't find event examples...
Thanks,
Daniel
0
Chris
Telerik team
answered on 30 Nov 2006, 04:33 PM
Hello Daniel,
You can use the TabItem property of the TabEventArgs to get the currently selected tab item. You could also access the SelectedTab property of the TabStrip control. If you would like to get the index of the selected tab item in the tabs collection you could use the Items.IndexOf method.
e.g.
radTabStrip1.Items.IndexOf(args.TabItem)

Regards,
Chris
the telerik team
0
Marturo77
Top achievements
Rank 1
answered on 18 May 2007, 08:08 PM
Hi.
 
I use this instrucction and receive the error:  

"Argument '1': cannot convert from 'Telerik.WinControls.RadElement' to 'Telerik.WinControls.RadItem'"

I use your instrucction inside of the radTabStrip_TabSelected event.

Can you help me?

Thanks
0
Mike
Top achievements
Rank 1
answered on 18 May 2007, 08:30 PM
Indeed, I tried the same and got the same compile time error. It appears that TabItem is of type RadElement, while the Items collection expects RadItem type. Please, try the following code instead - it worked in my case, hopefully this is applicable in your setup as well.

C#
private void radTabStrip1_TabSelected(object sender, TabEventArgs args) 
    int index = radTabStrip1.Items.IndexOf(args.TabItem as Telerik.WinControls.RadItem);         


VB.NET
Private Sub radTabStrip1_TabSelected(sender As Object, args As TabEventArgs) 
   Dim index As Integer = radTabStrip1.Items.IndexOf(CType(args.TabItem, Telerik.WinControls.RadItem )) 
End Sub 
 
 
 
 

0
Mike
Top achievements
Rank 1
answered on 19 May 2007, 09:49 AM
An Index property will come handy in this situation... most System.Windows.Forms child items have Index properties and we are used to that.

e.g.

            System.Windows.Forms.MenuItem item = new System.Windows.Forms.MenuItem();
            item.Index ..
0
Boyko Markov
Telerik team
answered on 21 May 2007, 12:40 PM
Hello Mike,

At present you could use the GetIndex method of TabStripElement which accepts a TabItem as a parameter and returns an integer with the index in the collection of that TabItem. We will add the Index property of TabItem in our next release of RadControls for WinForms.

If you would like to get the selected tab you could handle the TabSelected event:
 
TabItem item = args.TabItem as TabItem; 


    // Place your code here 
 


I hope that this helps. If you need any further assistance please do not hesitate to write us back.

 
Sincerely yours,
Ray
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Asked by
Daniel Plomp
Top achievements
Rank 2
Answers by
Chris
Telerik team
Mukunda Manoj
Top achievements
Rank 1
Daniel Plomp
Top achievements
Rank 2
Marturo77
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Boyko Markov
Telerik team
Share this question
or