Hi everybody,
I having trouble of displaying multiple instances of picturebox at runtime. Every time the user click mouse on particular area of main picture box control (contains an image), a Red Dot image appears, so clicking multiple times on different areas will display multiple Red Dot images (contain in PictureBox). And when you click same existing Red Dot image it will disappear or canceling that red dot on that location. I am also storing the data like coordinates. The problem is the second or next red dot does not appear. How to fixed showing multiple red dots Is there anyone who can help me Thanks.
Note: pbxMain - Main Picture Box where multiple Red Dot image suppose to appear.
Each Red dot images has a PictureBox as conatiner control.
Code:
private void pbxMain_Click(object sender, System.EventArgs e)
{
if (this.navicontrol != null)
{
//Get x-axis and y-axis of Red Dot image
int x = 0;
int y = 0;
.... Obtaining Data to be stored ...
if (!this.pbxRed.Visible) //First (Default Created at design Time) PictureBox
{
x = this.pbxRed.Location.X;
y = this.pbxRed.Location.Y;
}
... Storing Data and Sending Coordinates ...
}
}
private void pbxMain_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
try
{
int imgX = e.X;
int imgY = e.Y - 8;
Point locPt = new Point(imgX,imgY);
//Get x-axis and y-axis of Red Dot image
int x = 0;
int y = 0;
.... Obtaining Data to be stored ...
if (!this.pbxRed.Visible)
{
this.pbxRed.Location = locPt;
this.pbxRed.Visible = true;
x = this.pbxRed.Location.X;
y = this.pbxRed.Location.Y;
... Storing Data and Sending Coordinates ...
}
else if (this.pbxRed2 == null)
{
this.CreateRedDot(true,locPt);
x = this.pbxRed2.Location.X;
y = this.pbxRed2.Location.Y;
... Storing Data and Sending Coordinates ...
}
..... Other functions ....
}
catch (Exception ex)
{
...Logging error ...
}
}
//For cancelling or Making existing Red Dot image disaaper
private void pbxRed_Click(object sender, System.EventArgs e)
{
//Get x-axis and y-axis of Red Dot image
int x = this.pbxRed.Location.X;
int y = this.pbxRed.Location.Y;
.... Obtaining Data to be stored ...
//Canceling if coordinates are same from previous fault location
}
private void CreateRedDot(bool bVisible, Point imgPt)
{
string filePath = Application.StartupPath + "\\RedDot.gif";
pbxRed2 = new PictureBox();
pbxRed2.Image = Image.FromFile(filePath); // No error happens here. Working fine
pbxRed2.Location = imgPt;
this.Controls.Add(pbxRed2);
if (bVisible)
pbxRed2.Visible = true;
else
pbxRed2.Visible = false;
}
den2005

How to Display Multiple Image on a main PictureBox control?
Eric.d
den2005
Doru Roman