Click here to Skip to main content
15,910,009 members
Home / Discussions / C#
   

C#

 
AnswerRe: basic web service help Pin
André Kraak8-Oct-11 13:48
André Kraak8-Oct-11 13:48 
GeneralRe: basic web service help Pin
SFORavi12-Oct-11 21:03
SFORavi12-Oct-11 21:03 
QuestionMerge Modules for Crystal Report 2008 Pin
sathyan_82948-Oct-11 6:18
sathyan_82948-Oct-11 6:18 
AnswerRe: Merge Modules for Crystal Report 2008 Pin
Eddy Vluggen8-Oct-11 7:01
professionalEddy Vluggen8-Oct-11 7:01 
GeneralRe: Merge Modules for Crystal Report 2008 Pin
Luc Pattyn8-Oct-11 7:59
sitebuilderLuc Pattyn8-Oct-11 7:59 
GeneralRe: Merge Modules for Crystal Report 2008 Pin
Eddy Vluggen8-Oct-11 8:17
professionalEddy Vluggen8-Oct-11 8:17 
GeneralRe: Merge Modules for Crystal Report 2008 Pin
Luc Pattyn8-Oct-11 8:20
sitebuilderLuc Pattyn8-Oct-11 8:20 
Questionproblem with scrollbars auto positioning during dragging a panel Pin
Abhishrek8-Oct-11 5:22
Abhishrek8-Oct-11 5:22 
Hello all,

Situation:
A Win Form, having a panel in it.
size of the panel is bigger than the form itself.
scrollbars are enabled on form and are working fine to scroll through the panel.
http://img824.imageshack.us/img824/1388/panelv.png[^]

Requirement:
1. Enable dragging the panel to see the hidden portion of the panel.
2. Auto align the Scrollbars properly

Problem:
I wrote a code and it does drag the panel but not working so good. it often misposition the scrollbars, and abruptly change the dragged psition.

Help Required:
1. What am i doing wrong ?
2. Is there a better way ?

Here is my code:
public partial class Form1 : Form
   {
       Point clickPoint = new Point();

       public Form1()
       {
           InitializeComponent();

           panel1.Location = new Point(0, 0);
           this.HorizontalScroll.SmallChange = 1;
           this.VerticalScroll.SmallChange = 1;
       }

       private void panel1_MouseDown(object sender, MouseEventArgs e)
       {
           if(e.Button == System.Windows.Forms.MouseButtons.Left)
               clickPoint = e.Location;
       }

       private void panel1_MouseMove(object sender, MouseEventArgs e)
       {
           if (e.Button == System.Windows.Forms.MouseButtons.Left)
           {
               Point diff = new Point(
                     clickPoint.X - e.Location.X,
                     clickPoint.Y - e.Location.Y);

               // Add the difference to scrollbars current value
               this.HorizontalScroll.Value =
                  Math.Min(Math.Max((this.HorizontalScroll.Value + diff.X),
                  this.HorizontalScroll.Minimum),
                  this.HorizontalScroll.Maximum);

               this.VerticalScroll.Value =
                  Math.Min(Math.Max((this.VerticalScroll.Value + diff.Y),
                  this.VerticalScroll.Minimum),
                  this.VerticalScroll.Maximum);

               // This also gives the same problem
               /*
               this.HorizontalScroll.Value =
                  Math.Min(Math.Max((this.HorizontalScroll.Value + diff.X),
                  this.HorizontalScroll.Minimum),
                  (panel1.Width-this.ClientRectangle.Width)); // <- here

               this.VerticalScroll.Value =
                  Math.Min(Math.Max((this.VerticalScroll.Value + diff.Y),
                  this.VerticalScroll.Minimum),
                  (panel1.Height - this.ClientRectangle.Height)); // <- here
               */
           }
       }
   }


And relocating the Panel is not what want:
Panel1.left += e.X - clickPoint.X; // Bad Idea
Panel1.top += e.Y - clickPoint.Y; // Bad Idea


modified 8-Oct-11 22:38pm.

AnswerRe: problem with scrollbars auto positioning during dragging a panel Pin
Luc Pattyn8-Oct-11 5:44
sitebuilderLuc Pattyn8-Oct-11 5:44 
GeneralRe: problem with scrollbars auto positioning during dragging a panel Pin
Abhishrek8-Oct-11 6:17
Abhishrek8-Oct-11 6:17 
AnswerRe: problem with scrollbars auto positioning during dragging a panel Pin
Luc Pattyn8-Oct-11 7:57
sitebuilderLuc Pattyn8-Oct-11 7:57 
GeneralRe: problem with scrollbars auto positioning during dragging a panel Pin
Abhishrek8-Oct-11 16:37
Abhishrek8-Oct-11 16:37 
AnswerRe: problem with scrollbars auto positioning during dragging a panel Pin
Luc Pattyn8-Oct-11 16:45
sitebuilderLuc Pattyn8-Oct-11 16:45 
AnswerRe: problem with scrollbars auto positioning during dragging a panel Pin
Luc Pattyn9-Oct-11 13:30
sitebuilderLuc Pattyn9-Oct-11 13:30 
GeneralRe: problem with scrollbars auto positioning during dragging a panel Pin
Abhishrek9-Oct-11 15:18
Abhishrek9-Oct-11 15:18 
AnswerRe: problem with scrollbars auto positioning during dragging a panel Pin
Luc Pattyn9-Oct-11 16:49
sitebuilderLuc Pattyn9-Oct-11 16:49 
QuestionCaptcha Control Pin
Nolee K8-Oct-11 0:02
Nolee K8-Oct-11 0:02 
AnswerRe: Captcha Control Pin
PIEBALDconsult8-Oct-11 4:32
mvePIEBALDconsult8-Oct-11 4:32 
QuestionFinding values in strings Pin
CCodeNewbie7-Oct-11 10:46
CCodeNewbie7-Oct-11 10:46 
AnswerRe: Finding values in strings Pin
PIEBALDconsult7-Oct-11 12:09
mvePIEBALDconsult7-Oct-11 12:09 
AnswerRe: Finding values in strings Pin
André Kraak7-Oct-11 12:47
André Kraak7-Oct-11 12:47 
AnswerRe: Finding values in strings Pin
Dave Kreskowiak7-Oct-11 12:58
mveDave Kreskowiak7-Oct-11 12:58 
AnswerRe: Finding values in strings Pin
Luc Pattyn7-Oct-11 16:14
sitebuilderLuc Pattyn7-Oct-11 16:14 
GeneralRe: Finding values in strings Pin
Dave Kreskowiak7-Oct-11 17:31
mveDave Kreskowiak7-Oct-11 17:31 
GeneralRe: Finding values in strings Pin
CCodeNewbie8-Oct-11 20:24
CCodeNewbie8-Oct-11 20:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.