Link to home
Start Free TrialLog in
Avatar of Milkus1
Milkus1Flag for Australia

asked on

Drag ' n ' Drop from Listview to Panel

I am currently building an application that allows the user to set up the dimensions of a room, then add pieces of funiture to the room (all to scale).
I was wanting to use the listview control for showing the furniture items, and a panel control is used as a 'snap grid' room.
Now the icons in the listview are not the same ones to be dragged onto the panel. What I would like to be able to do is either drag n drop the correctly scaled piece of furniture onto the panel, or have it appear on the panel when selected( much like a Real time strategy game). The user can then position it, rotate etc as needed.

Background out of the way, how do I select the right size graphic when I click on the listview, display it for dragging and drop it onto the panel. I have only 3 ratios to work with (1:1, 7:10, 1:2), which is determined when the room dimensions are chosen. May initial thoughts is to just build graphics in all 3 dimensions and stick them in a imagelist, on selection choose the correct sized graphic and then create a picturebox on the panel to stick it in. Sounds okay in theory, but VB.NET is not VB6, which is where I'm falling down. Any help is appreciated.
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Not sure exactly where you want help at...

Seperate PictureBoxes for each piece of furniture will make moving them easy.  Also, if you set the AutoScroll property of the Panel to True then you have an instant scrollable room.

You can use the DrawImage() function to scale your graphics for the different ratios.

~IM
Avatar of Milkus1

ASKER

Thanks IdleMind,
what I need help with is how do I make the picturebox array at runtime, in VB.NET and the handlers for the boxes. Or display the correct graphic for dragging onto the panel? A room may have 50 pieces of furniture, all which need to be tracked, rotated, snapped to a grid. etc.
If I could do it like SIMCITY or Warcraft type mechanics I would be very happy. You know where the 'piece' is moved around with the cursor until its dropped.
Currently I can click an Item and make 1 picturebox appear in the room with the correct graphic, but not an array of them.

 I'll check into the drawimage function to handle the sizing issue.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Milkus1

ASKER

Legend!!! Thanks Idle Mind...all points for you this looks exactly what I need!
I love this site, and guys like you who help out.