PC Review


Reply
Thread Tools Rate Thread

How to drag a picturebox inside a panel control?

 
 
Steven Garrad
Guest
Posts: n/a
 
      30th Apr 2007
Hi All,
I have a pictureBox control inside of a panel control. The pictureBox is
larger than the panel control and I have the panel control set true for
AutoScroll so the panel displays scrolling bars.

I would like the user to be able to click and drag the image and for it to
move around within the panel control.

How would I do this?

Cheers,
Steve
 
Reply With Quote
 
 
 
 
Alex Meleta
Guest
Posts: n/a
 
      1st May 2007
Steve,

The simple way to just move the picture by clicking is:

// Define a location before move
int x;
int y;

// Storing begin point (by the left click)
void pictureBox_MouseDown(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
x = e.X;
y = e.Y;
} }

// Moving the picture
void pictureBox_MouseMove(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
pictureBox1.Left += (e.X - x);
pictureBox1.Top += (e.Y - y);
} }

Alex
http://devkids.blogspot.com




> Hi All,
> I have a pictureBox control inside of a panel control. The pictureBox
> is
> larger than the panel control and I have the panel control set true
> for
> AutoScroll so the panel displays scrolling bars.
> I would like the user to be able to click and drag the image and for
> it to move around within the panel control.
>
> How would I do this?
>
> Cheers,
> Steve



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MMC TV's control panel is embedded inside TV picture zeke7 ATI Video Cards 6 4th Jan 2008 07:47 AM
Re: keyboard peoperties inside control panel is gone gls858 Windows Vista General Discussion 0 11th Jun 2007 07:10 PM
Custom web control with two TextBox inside a panel =?Utf-8?B?V2lsc29u?= Microsoft C# .NET 1 1st Jul 2006 05:31 AM
Missing controls inside Panel control shustes Microsoft Dot NET 0 26th Jul 2005 05:37 PM
Moving a control inside an Autoscroll Panel Alejandro Serrano Microsoft Dot NET Framework Forms 0 17th Jul 2005 11:32 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:04 PM.