Panel offset index property

pettrer

Well-known member
Joined
Sep 5, 2008
Messages
92
Programming Experience
10+
Hi,

I use drag'n'drop from a datagridview to a panel. The panel holds an array of objects (think rows) so that the items from the datagridview can be dragged to the different objects. I use the y-index from the top of the panel to define what object the item is dragged onto.

This works great as long as the object is visible from the start. However, if I scroll down to an object and then drag the item from the dgv, it gets released on the wrong object, as the y-index doesn't take into account the number of pixels I scrolled down. So, what I need is (if it exists) the scroll offset property for the panel, i.e., the number of pixels that I scrolled down. (Then I can add this offset integer to the y coordinate on which the user drops his/her object.)

Thanks in advance for any help!

Warm regards from a rainy Stockholm,

Pettrer
 
I think more info is needed.
The panel holds an array of objects (think rows)
Does not mean much without knowing what these objects are.
Why not capture the objects by the mouse coordinates in the DragDrop event?
 
Hello,

Thanks for answering. Actually, what I'm doing is mimicing a dgv, using a panel as a container. I fill this container with labels that are created dynamically, from data in a parent array and data in the parent array's child arrays. The reason for doing this is that the dgv doesn't allow "subcells" in the dgv rows.

However, I think this doesn't really matter much. :) What I need help with is find the y offset integer in a panel that has been scrolled. I guess a property like this exists, but I can't find it via Google (or rather Bing).

Thanks again for your interest in my problem,

Pettrer
 
You can use the Labels as drop targets, configure them to allow drop and AddHandler for their drag-drop events.
 
Hello John,

Thanks for your reply. I understand this also, but the code involved holds two thousand (badly converted VB code) lines, and the only problem I have now is the y offset, so I'd really like a solution with the offset property (if such a property exists)...

Do you know if there is one?

Warm regards,

Pettrer
 
Hi,

I found it at last, not online but in Visual Studio. In case anyone needs it, here's how (verticalscroll of the control you're interested in):

VB.NET:
Dim Musposition As Point
Musposition = pSalar.PointToClient(Cursor.Position)
Musposition.Y += pSalar.VerticalScroll.Value

Thanks again,

Pettrer
 
Back
Top