473,396 Members | 1,764 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,396 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 2306
\\\
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.