This is a migrated thread and some comments may be shown as answers.

radTabStrip DragDrop

2 Answers 52 Views
Tabstrip (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Marc
Top achievements
Rank 2
Marc asked on 09 Jan 2009, 11:00 AM
I am trying to implment the ability for another control to drag and drop onto tabs in a radTabStrip.  I have been able to implment most of it, but am having difficulty determining which tab the user dropped on. 

I would have thought I could put the following code in the DragDrop event of the TabStrip, but the GetItemByPoint always returns nothing, even when tabs were dropped on.

Dim tab As Telerik.WinControls.UI.TabItem  
 
tab = radTabStrip.TabStripElement.GetItemByPoint(New Point(e.X, e.Y))  
 
If tab IsNot Nothing Then  
    MsgBox(tab.Name)  
End If  
 

Any help would be appreciated.

I am using VB.NET in VS2008

Thank you -- controls are still fantastic

2 Answers, 1 is accepted

Sort by
0
Accepted
Victor
Telerik team
answered on 09 Jan 2009, 05:09 PM
Hi Marc,

Thanks for writing.
You can get a reference to the tab you are dropping on by iterating over the Items collection of the RadTabStrip and checking if its Bounds property contains the point that you clicked on. A somewhat subtle detail is that you have to convert the Bounds rectangle to screen coordinates since e.X and e.Y are in screen coordinates.
Here is the code:
Private Sub RadTabStrip1_DragDrop(ByVal sender As System.ObjectByVal e As System.Windows.Forms.DragEventArgs) Handles RadTabStrip1.DragDrop  
        Dim i As Integer 
        Dim p As Point  
        p.X = e.X  
        p.Y = e.Y  
        For i = 0 To RadTabStrip1.Items.Count - 1  
            If RadTabStrip1.Items(i).RectangleToScreen(RadTabStrip1.Items(i).Bounds).Contains(p) Then 
                MessageBox.Show("Found tab item! This is " + RadTabStrip1.Items(i).Text)  
                RadTabStrip1.Items(i).Text = e.Data.GetData(GetType(String)).ToString()  
                RadTabStrip1.Items(i).ForeColor = Color.Red  
            End If 
        Next 
    End Sub 
Please do write again if you have more questions.

All the best,
Victor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Marc
Top achievements
Rank 2
answered on 09 Jan 2009, 05:55 PM
Yep, that did it!

   
Tags
Tabstrip (obsolete as of Q2 2010)
Asked by
Marc
Top achievements
Rank 2
Answers by
Victor
Telerik team
Marc
Top achievements
Rank 2
Share this question
or