string currentPath = System.IO.Directory.GetCurrentDirectory();//路径到\bin\Debug string[] strArray = currentPath.Split(new string[] { @"\bin" }, StringSplitOptions.RemoveEmptyEntries); string basepath = currentPath.Split(new string[] { @"\bin" }, StringSplitOptions.None)[0]; string picPath = basepath + "\pic\移交的工程资料.png"; this.pictureBox1.SizeMode = PictureBoxSizeMode.Normal; this.pictureBox1.Image = Image.FromFile(picPath); this.pictureBox1.Dock = DockStyle.Fill; string picPath2 = basepath + "\pic\档案示例.png"; this.pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage; this.pictureBox2.Image = Image.FromFile(picPath2); this.pictureBox2.Dock = DockStyle.Fill;
代码如上,请各位大大帮帮本人,谢谢
解决方案
20
this.pictureBox2.Dock = DockStyle.Fill; 不是把第一个覆盖了?你把两个图片控件的这个属性都注释掉看下,假如还不行的话就先不通过程序控制先在窗体中手动给两个控件选择下图片看下是什么效果?