W
weird0
I have been successful in making an array of picturebox and writing
event handlers for them, after hours of hard work. I want to drag and
drop all of the pictureboxes. And they dont.!!!! :-( Can somebody
help me this? What code should i write in the event handlers so that i
make all the picture boxes to drag and drop ?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace PicBoxApp
{
public partial class Form1 : Form
{
private System.Windows.Forms.PictureBox[] PicBoxes;
Rectangle dropRect = new Rectangle(180, 180, 60, 60);
private PictureBox myPictureBox;
public Form1()
{
InitializeComponent();
CenterToScreen();
PicBoxes = new System.Windows.Forms.PictureBox[8];
myPictureBox = new PictureBox();
myPictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
myPictureBox.Location = new System.Drawing.Point(64, 32);
myPictureBox.Size = new System.Drawing.Size(50, 50);
myPictureBox.Image = new Bitmap(@"D:\Documents and
Settings
\All Users\Documents\My Pictures\Sample Pictures\winter.jpg");
//myPictureBox.MouseDown += new
MouseEventHandler(myPictureBox_MouseDown);
//myPictureBox.MouseUp += new
MouseEventHandler(myPictureBox_MouseUp);
//myPictureBox.MouseMove += new
MouseEventHandler(myPictureBox_MouseMove);
//myPictureBox.Cursor = Cursors.Hand;
//initialise each picture box
for (i = 0; i < NodesLimit; i++)
{
//allocate the picture box
PicBoxes = new PictureBox();
PicBoxes.Name = i.ToString();
//set up the initial properties
PicBoxes.Top = (i + 1) * 30;
PicBoxes.Left = (i + 1) * 20;
PicBoxes.Width = 150;
PicBoxes.Height = 100;
PicBoxes.SizeMode =
PictureBoxSizeMode.StretchImage;
PicBoxes.Image = Image.FromFile(@"D:\Documents and
Settings\All Users\Documents\My Pictures\Sample Pictures
\Winter.jpg");
//we are putting the index into the Tag property so
we
can access this like any other array
PicBoxes.Tag = i;
//Here we are wiring this picture boxes click to our
new common click handler.
PicBoxes.Click += new
System.EventHandler(ClickHandler);
PicBoxes.MouseDown += new
System.Windows.Forms.MouseEventHandler(MouseDown);
PicBoxes.MouseDown += new
System.Windows.Forms.MouseEventHandler(MouseUp);
PicBoxes.MouseDown += new
System.Windows.Forms.MouseEventHandler(MouseMove);
}
this.Controls.AddRange(PicBoxes);
Controls.Add(myPictureBox);
}
//This is the new click handling function for our array of
boxes
public void ClickHandler(Object sender, System.EventArgs e)
{
}
private void MouseDown(object sender, MouseEventArgs e)
{
}
private void MouseMove(object sender, MouseEventArgs e)
{
}
private void MouseUp(object sender, MouseEventArgs e)
{
}
private void Form1_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
}
}
}
Here are the links, where i took help:
http://pages.cpsc.ucalgary.ca/~carman/481/examples/csharp/controlarra...
http://www.java2s.com/Code/CSharp/GUI-Windows-Form/DraganddropthePict...
Need help
Regards
event handlers for them, after hours of hard work. I want to drag and
drop all of the pictureboxes. And they dont.!!!! :-( Can somebody
help me this? What code should i write in the event handlers so that i
make all the picture boxes to drag and drop ?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace PicBoxApp
{
public partial class Form1 : Form
{
private System.Windows.Forms.PictureBox[] PicBoxes;
Rectangle dropRect = new Rectangle(180, 180, 60, 60);
private PictureBox myPictureBox;
public Form1()
{
InitializeComponent();
CenterToScreen();
PicBoxes = new System.Windows.Forms.PictureBox[8];
myPictureBox = new PictureBox();
myPictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
myPictureBox.Location = new System.Drawing.Point(64, 32);
myPictureBox.Size = new System.Drawing.Size(50, 50);
myPictureBox.Image = new Bitmap(@"D:\Documents and
Settings
\All Users\Documents\My Pictures\Sample Pictures\winter.jpg");
//myPictureBox.MouseDown += new
MouseEventHandler(myPictureBox_MouseDown);
//myPictureBox.MouseUp += new
MouseEventHandler(myPictureBox_MouseUp);
//myPictureBox.MouseMove += new
MouseEventHandler(myPictureBox_MouseMove);
//myPictureBox.Cursor = Cursors.Hand;
//initialise each picture box
for (i = 0; i < NodesLimit; i++)
{
//allocate the picture box
PicBoxes = new PictureBox();
PicBoxes.Name = i.ToString();
//set up the initial properties
PicBoxes.Top = (i + 1) * 30;
PicBoxes.Left = (i + 1) * 20;
PicBoxes.Width = 150;
PicBoxes.Height = 100;
PicBoxes.SizeMode =
PictureBoxSizeMode.StretchImage;
PicBoxes.Image = Image.FromFile(@"D:\Documents and
Settings\All Users\Documents\My Pictures\Sample Pictures
\Winter.jpg");
//we are putting the index into the Tag property so
we
can access this like any other array
PicBoxes.Tag = i;
//Here we are wiring this picture boxes click to our
new common click handler.
PicBoxes.Click += new
System.EventHandler(ClickHandler);
PicBoxes.MouseDown += new
System.Windows.Forms.MouseEventHandler(MouseDown);
PicBoxes.MouseDown += new
System.Windows.Forms.MouseEventHandler(MouseUp);
PicBoxes.MouseDown += new
System.Windows.Forms.MouseEventHandler(MouseMove);
}
this.Controls.AddRange(PicBoxes);
Controls.Add(myPictureBox);
}
//This is the new click handling function for our array of
boxes
public void ClickHandler(Object sender, System.EventArgs e)
{
}
private void MouseDown(object sender, MouseEventArgs e)
{
}
private void MouseMove(object sender, MouseEventArgs e)
{
}
private void MouseUp(object sender, MouseEventArgs e)
{
}
private void Form1_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
}
}
}
Here are the links, where i took help:
http://pages.cpsc.ucalgary.ca/~carman/481/examples/csharp/controlarra...
http://www.java2s.com/Code/CSharp/GUI-Windows-Form/DraganddropthePict...
Need help
Regards