C# 如何制作图片框表单
我无法使我的图片框显示在表单上。我做错了吗?这是我的代码:
static Bitmap[] pictures = new Bitmap[9];
PictureBox[] picBox= new PictureBox[9];
在构造函数上:
pictures[1] = new Bitmap(@"1.1Bright.jpg");
* picBox[1].Location = new System.Drawing.Point(25, 7);
picBox[1].SizeMode = PictureBoxSizeMode.StretchImage;
picBox[1].ClientSize = new Size(53, 40);
picBox[1].Image = pictures[1];
我不断收到 * 上的 nullreferenceException 错误
I'm unable to make my pictureboxes to be shown on form. Am i doing it wrong or? This is my code:
static Bitmap[] pictures = new Bitmap[9];
PictureBox[] picBox= new PictureBox[9];
on the constructor :
pictures[1] = new Bitmap(@"1.1Bright.jpg");
* picBox[1].Location = new System.Drawing.Point(25, 7);
picBox[1].SizeMode = PictureBoxSizeMode.StretchImage;
picBox[1].ClientSize = new Size(53, 40);
picBox[1].Image = pictures[1];
I keep getting nullreferenceexception error on *
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您尚未设置
picBox[1]
来引用任何内容。您需要这样的东西:您真的希望
pictures
变量是静态的吗?每次创建表单实例时,数组内容都会被覆盖...You haven't set
picBox[1]
to reference anything. You need something like:Do you really want the
pictures
variable to be static though? The array contents will be overwritten every time you create an instance of the form...知道了:
got it: