473,324 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

dragdrop and tabcontrol

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
Jul 21 '05 #1
2 2301
\\\
Private Sub tc_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) _
Handles tc.DragDrop
Dim pt As Point = tc.PointToClient(New Point(e.X, e.Y))
Dim hover_tab As TabPage = GetTabPageByTab(pt)
If Not hover_tab Is Nothing Then
Debug.Write(hover_tab.ToString)
End If
End Sub

Private Function GetTabPageByTab(ByVal pt As Point) As TabPage
For index As Integer = 0 To tc.TabCount - 1
If tc.GetTabRect(index).Contains(pt.X, pt.Y) Then
Return tc.TabPages(index)
End If
Next
Return Nothing
End Function

Private Sub tc_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs) _
Handles tc.DragEnter
e.Effect = DragDropEffects.All
End Sub
///

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"dave" <da**@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
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

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004
Jul 21 '05 #2
Thank you very much Mike. (I owe you one)

It appears my biggest fault was the issue that pointtoclient is a method of
the tabcontrol. Thanks again.
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Kate | last post by:
Hi: I have a form with a picture box and some command buttons to make certain shapes appear in the picture box. The shapes are drawn on blank UserControls added like this: 'at top of form...
10
by: KS | last post by:
I have a Button I want to pull to a Label. I want the Button visualy to move when I pull it. When I drop the button on the Label I want to test some data coming with the Button - f.ex is the...
1
by: KS | last post by:
In want to visualy drag a Button to a Label and when I depress the mousebutton on top of the label I want to show some dato from the Button in a MsgBox - that's my primary goal. I have made a...
0
by: Flack | last post by:
Hello, Is it possible to find out how many methods are listening to a certain event? For example, if a number of methods subscribed to a controls DragDrop event using +=, can I find out how many...
0
by: Gene Hubert | last post by:
Well, it seems fundamental to me anyway. Hopefully it is simple enough. The question is for when the source for the dragdrop is a different application that the target for the dragdrop. How...
3
by: Gary Dunne | last post by:
I'm writing an app that requires drag and drop operation between a ListView and a TreeView control. (The source is the ListView). During the drag drop operation I want to be able to detect the...
7
by: JohnR | last post by:
I am using dragdrop to drag and drop a custom class instance. When I drag/drop from one window to another window in the same application everything works fine. But when trying to move between the...
2
by: dave | last post by:
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.