Actually I do not know what is wrong with my codes. Because I am trying to declare the x and y values for my picturebox.
The picturebox will be loaded during run time only. So how could I use the picturebox_mousemove event?
here is my code for the addingcontroltoform
//Add Control to form
private void AddtbCtrl1toForm(System.IO.FileInfo Fi)
{
Image img = null;
try
{
img = Image.FromFile(Fi.FullName);
this.FleLst.Items.Add(Fi.Name);
TabPage tp = new TabPage();
Panel pnl = new Panel();
PictureBox PB = new ImageBox();
tp.Text = Fi.Name;
//panel
pnl.AutoScroll = AutoScroll = true;
pnl.Location = new Point(3, 3);
pnl.Size = new Size(566, 574);
pnl.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
tp.Controls.Add(pnl);
//picturebox
PB.Location = new Point(25, 25);
PB.Size = new Size(520, 535);
PB.SizeMode = PictureBoxSizeMode.AutoSize;
pnl.Controls.Add(PB);
PB.Image = img;
this.tbCtrl1.TabPages.Add(tp);
}
catch
{
if (img != null)
img.Dispose();
}
}
and for my picturebox_mousemove event.
// Picture Box Control for X and Y
private void ImgBx_MouseMove(object sender, MouseEventArgs e)
{
if (imgbx.Image != null)
{
this.XposTlStrpLbl.Text = " " + e.X.ToString();
this.YposTlStrpLbl.Text = " " + e.Y.ToString();
if (gray_in_use)
{
this.XYValTlStrpLbl.Text = " " + GryImg[e.Y, e.X].ToString();
}
else
{
this.XYValTlStrpLbl.Text = " " + MImg[e.Y, e.X].ToString();
}
}
}
thanks

New Topic/Question
Reply



MultiQuote





|