473,772 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(ByV al sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles tc.DragDrop
Dim pt As New Point(e.X, e.Y)
pt = PointToClient(p t)
Dim hover_tab As TabPage = GetTabPageByTab (e.X, e.Y)
If Not hover_tab Is Nothing Then
Debug.Write("go t 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.Cou nt - 1
Dim tabRec As System.Drawing. Rectangle = tc.GetTabRect(i )
Debug.WriteLine (DateTime.Now.T oString & " " & i.ToString &
tabRec.X & " " & tabRec.Y & " Point X " & x & " " & y & "____")

If tc.GetTabRect(i ).Contains(x, y) Then
tp = tc.TabPages(i)
tc.SelectedInde x = i
Debug.WriteLine (DateTime.Now.T oString & " " & i.ToString)
Exit For
End If
Next
Return tp
End Function
Jul 21 '05 #1
2 2341
\\\
Private Sub tc_DragDrop(ByV al sender As Object, ByVal e As DragEventArgs) _
Handles tc.DragDrop
Dim pt As Point = tc.PointToClien t(New Point(e.X, e.Y))
Dim hover_tab As TabPage = GetTabPageByTab (pt)
If Not hover_tab Is Nothing Then
Debug.Write(hov er_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(i ndex).Contains( pt.X, pt.Y) Then
Return tc.TabPages(ind ex)
End If
Next
Return Nothing
End Function

Private Sub tc_DragEnter(By Val 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**@discussio ns.microsoft.co m> wrote in message
news:E4******** *************** ***********@mic rosoft.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(ByV al sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles tc.DragDrop
Dim pt As New Point(e.X, e.Y)
pt = PointToClient(p t)
Dim hover_tab As TabPage = GetTabPageByTab (e.X, e.Y)
If Not hover_tab Is Nothing Then
Debug.Write("go t 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.Cou nt - 1
Dim tabRec As System.Drawing. Rectangle = tc.GetTabRect(i )
Debug.WriteLine (DateTime.Now.T oString & " " & i.ToString &
tabRec.X & " " & tabRec.Y & " Point X " & x & " " & y & "____")

If tc.GetTabRect(i ).Contains(x, y) Then
tp = tc.TabPages(i)
tc.SelectedInde x = i
Debug.WriteLine (DateTime.Now.T oString & " " & 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
5846
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 module Dim WithEvents tc As testControl 'button1_click (for example)
10
436
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 Button.Text="The right one!". I have some code that can do the DragDrop-effect BUT this code disables the visual effect og the Button visualy moving to the Label.
1
2525
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 simple sample code - a form with a Button1, a Label1 and a Timer1. The Button1 has Tag="SomeData", the Label1 has AllowDrop=True and the Timer1 has an Interval=20.
0
1323
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 methods in total are listening to the DragDrop event of the control? If I can't find out the exact number of methods listening to the DragDrop event, can I somehow remove all listeners of that event at once? I tried using m_Control.DragDrop =...
0
1019
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 does the source for the dragdrop operation know that a drop has been completed onto a valid target? And then, how does the source know what the drop target is? I've got dragdrop working within my application but I can't see any
3
3794
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 target node in the treeview and auto expand it if applicable... but after a fair bit of head scratching I can't find any easy way to accomplish this. I think what i really need is the equivalent of the HitTest method from the COM version of the...
7
4008
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 same windows running in different instances of the application the "dropped" data comes across as a system.__ComObject and I can't CType it to my class to extract the data. I've been searching for hours and haven't found any solution so I am...
2
345
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 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...
0
9620
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9912
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.