Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Fixed it!</p> <p>Old Code:</p> <pre><code>Barcode barcode = new Barcode(); pic = new PictureBox(); pic.Name = "bCode" + bNum; pic.SizeMode = PictureBoxSizeMode.AutoSize; pic.Image = barcode.createBarcode(BarcodeLib.TYPE.CODE128, 300, 100, "123456789"); pic.Show(); labelHolder.Controls.Add(pic); pic.BringToFront(); pic.MouseDown += pic_MouseDown; pic.MouseMove +=pic_MouseMove; pic.MouseUp += pic_MouseUp; } PictureBox thisPB; private void pic_MouseDown(object sender, MouseEventArgs e) { mouseDown = true; oldX = e.X; oldY = e.Y; } private void pic_MouseMove(object sender, MouseEventArgs e) { if(mouseDown) { thisPB.Location = new Point(pic.Location.X - (oldX - e.X), pic.Location.Y - (oldY - e.Y)); this.Refresh(); } } private void pic_MouseUp(object sender, MouseEventArgs e) { mouseDown = false; } </code></pre> <p>Working Code:</p> <pre><code>Barcode barcode = new Barcode(); pic = new PictureBox(); pic.Name = "bCode" + bNum; pic.SizeMode = PictureBoxSizeMode.AutoSize; pic.Image = barcode.createBarcode(BarcodeLib.TYPE.CODE128, 300, 100, "123456789"); pic.Show(); labelHolder.Controls.Add(pic); pic.BringToFront(); pic.MouseDown += pic_MouseDown; pic.MouseMove +=pic_MouseMove; pic.MouseUp += pic_MouseUp; } PictureBox thisPB; private void pic_MouseDown(object sender, MouseEventArgs e) { mouseDown = true; oldX = e.X; oldY = e.Y; } private void pic_MouseMove(object sender, MouseEventArgs e) { if(mouseDown) { thisPB = (PictureBox)sender; thisPB.Location = new Point(thisPB.Location.X - (oldX - e.X), thisPB.Location.Y - (oldY - e.Y)); this.Refresh(); } } private void pic_MouseUp(object sender, MouseEventArgs e) { mouseDown = false; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload