radTabStrip DragDrop

3 posts, 1 answers
  1. Marc
    Marc avatar
    21 posts
    Member since:
    Dec 2008

    Posted 09 Jan 2009 Link to this post

    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  
    End If  

    Any help would be appreciated.

    I am using VB.NET in VS2008

    Thank you -- controls are still fantastic
  2. Answer
    Victor avatar
    1349 posts

    Posted 09 Jan 2009 Link to this post

    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 
        End Sub 
    Please do write again if you have more questions.

    All the best,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. Marc
    Marc avatar
    21 posts
    Member since:
    Dec 2008

    Posted 09 Jan 2009 Link to this post

    Yep, that did it!

Back to Top