Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2006

Tip: Looking for answers? Try searching our database.

TabControl: How to know which tab the mouse is over

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anon - 19 Mar 2006 03:28 GMT
I am trying to do a drag and drop operation onto a TabControl...

Here's the scenario:
A TabControl has 5 tabs.
Each tab has a DataGridView

Drag and drop should be able to drag a row from one DataGridView (in one
tab) into another DataGridView (in another tab).
Being that only one DataGridView can be displayed, what I'll do is drag the
row over to the TOP of the TabControl where all of the 5 Tab Headers exist.
From there, if they "drop" the row, I would like to simply take the row out
of the Dragged DataGridView and place it into the DatGridView that's
contained within the tab that they chose to "drop" the row to.

I have a proof of concept partly working.   I can do the drag and drop,
however I'm having a problem getting the "tab" index of the tab that they
wish to drop it in...

Is there a way that I can tell which "tab" header (in a TabControl) the
mouse is over when the drop operation is performed?   In the DragDrop()
method, I have access to the X,Y coordinate.   I cannot find a method or
property which will allow me to figure out which "tab header" the mouse was
over.

I *could* try and generate a mouse click (by calling SendMessage()) and then
overriding the tabChanged() method and having that method determine if a
"drag" operation was in-progress by looking at a boolean (that DragDrop()
would set).  If the drag was in-progress, then the tabChanged() method can
conclude it got in the method due to a "drop".

Before I go off and figure out how to get SendMessage() to compile (I saw an
example of using the DllImport annotation (so I could call SendMessage() to
Generate a mouse click event) but could not get the example to compile), I'd
like to know if there is a way to determine which "tab header" corresponds
to an X,Y coordinate.

There is just one tab control in the application.

thanks again for any help....
Mick Doherty - 19 Mar 2006 11:08 GMT
Loop through the tabpages calling GetTabRect(index) and check if the
returned rectangle Contains(X,Y)

Signature

Mick Doherty
http://dotnetrix.co.uk/nothing.html

>I am trying to do a drag and drop operation onto a TabControl...
>
[quoted text clipped - 43 lines]
>
> thanks again for any help....
Anon - 19 Mar 2006 14:56 GMT
Awesome...

Thanks for the reply Mick.  This works great and is exactly what I was
looking for.

> Loop through the tabpages calling GetTabRect(index) and check if the
> returned rectangle Contains(X,Y)
[quoted text clipped - 46 lines]
> >
> > thanks again for any help....

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.