我想要做一个逻辑门程序。我试图用类NOT创建一个PictureBox
,问题是当我在form1中调用create方法时,它不会出现,并且当我单击列表项时,PictureBox
不会出现。问题是(我认为)即使使用FindForm()
方法,它也不知道它是在form1中。 而从调用它的形式PictureBox不会出现C#
---Source Code for NoT class---
class NOT: Shape
{
PictureBox px = new PictureBox();
Image img = Image.FromFile(@"C:\NOT.png");
public NOT(int x, int y) : base(x,y)
{
px.FindForm();
px.Visible = true;
px.Enabled = true;
}
public override void CreatePicture()
{
Point p1 = new Point(xx, yy);
px.Image = img;
px.Location = p1;
px.Show();
}
}
---Source code for the SHape Class---
abstract class Shape
{
protected int xx, yy; //private Point location;
public Shape(int X, int Y)
{
xx = X;
yy = Y;
}
public abstract void CreatePicture();
}
private void nOTToolStripMenuItem_Click(object sender, EventArgs e)
{
nt.CreatePicture();
}
NOT nt = new NOT(12,23);
但你永远不会告诉图片框,它应该住在窗体内!所以它位于空间中(或者在程序的记忆中,但没有人画出它).. – gbianchi