G
Guest
I am wishing to drag something from the desktop to a tab of a tab control in
vb.net.
The dragdrop event fires when release the mouse above the tab however i am
having a hard time trying to figure out which tab it was dropped on.
Currently i am using the following code but it is not working..Any help
would be appreciated...
Private Sub tc_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles tc.DragDrop
Dim pt As New Point(e.X, e.Y)
pt = PointToClient(pt)
Dim hover_tab As TabPage = GetTabPageByTab(e.X, e.Y)
If Not hover_tab Is Nothing Then
Debug.Write("got it")
End If
End Sub
Private Function GetTabPageByTab(ByVal x As Integer, ByVal y As Integer)
As TabPage
'Private Function GetTabPageByTab(ByVal pt As Point) As TabPage
Dim tp As TabPage = Nothing
Dim i As Integer = 0
For i = 0 To tc.TabPages.Count - 1
Dim tabRec As System.Drawing.Rectangle = tc.GetTabRect(i)
Debug.WriteLine(DateTime.Now.ToString & " " & i.ToString &
tabRec.X & " " & tabRec.Y & " Point X " & x & " " & y & "____")
If tc.GetTabRect(i).Contains(x, y) Then
tp = tc.TabPages(i)
tc.SelectedIndex = i
Debug.WriteLine(DateTime.Now.ToString & " " & i.ToString)
Exit For
End If
Next
Return tp
End Function
vb.net.
The dragdrop event fires when release the mouse above the tab however i am
having a hard time trying to figure out which tab it was dropped on.
Currently i am using the following code but it is not working..Any help
would be appreciated...
Private Sub tc_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles tc.DragDrop
Dim pt As New Point(e.X, e.Y)
pt = PointToClient(pt)
Dim hover_tab As TabPage = GetTabPageByTab(e.X, e.Y)
If Not hover_tab Is Nothing Then
Debug.Write("got it")
End If
End Sub
Private Function GetTabPageByTab(ByVal x As Integer, ByVal y As Integer)
As TabPage
'Private Function GetTabPageByTab(ByVal pt As Point) As TabPage
Dim tp As TabPage = Nothing
Dim i As Integer = 0
For i = 0 To tc.TabPages.Count - 1
Dim tabRec As System.Drawing.Rectangle = tc.GetTabRect(i)
Debug.WriteLine(DateTime.Now.ToString & " " & i.ToString &
tabRec.X & " " & tabRec.Y & " Point X " & x & " " & y & "____")
If tc.GetTabRect(i).Contains(x, y) Then
tp = tc.TabPages(i)
tc.SelectedIndex = i
Debug.WriteLine(DateTime.Now.ToString & " " & i.ToString)
Exit For
End If
Next
Return tp
End Function