C# picturebox好几个不能完全显示

问题描述

在winform上画了很多pictruebox的控件,一行四个,一共两行,但是只能显示第一个和最后一个的图片,将其他的注释了之后再显示还是第一个和第八个问问怎么解决?

解决方案

解决方案二:
代码贴出来没代码的情况,个人估计是loction位置覆盖了当然我个人建议使用FlowlayeroutPanel,代替普通panel,这样就无需考虑location的位置了,只管control.add就是
解决方案三:
注意每个picturebox的location。
解决方案四:
引用1楼wanghui0380的回复:

代码贴出来没代码的情况,个人估计是loction位置覆盖了当然我个人建议使用FlowlayeroutPanel,代替普通panel,这样就无需考虑location的位置了,只管control.add就是

stringfptrain1=ds.Tables[0].Rows[arrayOrder[0]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain1);stringfptrain2=ds.Tables[0].Rows[arrayOrder[1]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain2);stringfptrain3=ds.Tables[0].Rows[arrayOrder[2]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain3);stringfptrain4=ds.Tables[0].Rows[arrayOrder[3]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain4);stringfptrain5=ds.Tables[0].Rows[arrayOrder[4]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain5);stringfptrain6=ds.Tables[0].Rows[arrayOrder[5]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain6);stringfptrain7=ds.Tables[0].Rows[arrayOrder[6]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain7);stringfptrain8=ds.Tables[0].Rows[arrayOrder[7]-1]["file_path"].ToString();this.pictureBox8.Image=Image.FromFile("E://character_whole//"+fptrain8);特别蠢的显示。。
解决方案五:
引用2楼guwei4037的回复:

注意每个picturebox的location。

location我在窗体显示界面看过了是对的。。
解决方案六:
额,这个请确保图像路径正确,同时需要设置一下picturebox滴sizemode,正常情况我一般设置为StretchImage或zoom当然具体情况你自己选择http://www.cnblogs.com/lv8218218/archive/2010/12/06/1897741.html
解决方案七:
调试看一下图片的路径是否正确。
解决方案八:
看这代码简直要犯密集恐惧症,能不能用数组,看着很简单估计就是文件不存在
解决方案九:
引用7楼tcmakebest的回复:

看这代码简直要犯密集恐惧症,能不能用数组,看着很简单估计就是文件不存在

真的存在。。但是就是显示不出来
解决方案十:
引用3楼lina181的回复:

Quote: 引用1楼wanghui0380的回复:
代码贴出来没代码的情况,个人估计是loction位置覆盖了当然我个人建议使用FlowlayeroutPanel,代替普通panel,这样就无需考虑location的位置了,只管control.add就是

stringfptrain1=ds.Tables[0].Rows[arrayOrder[0]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain1);stringfptrain2=ds.Tables[0].Rows[arrayOrder[1]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain2);stringfptrain3=ds.Tables[0].Rows[arrayOrder[2]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain3);stringfptrain4=ds.Tables[0].Rows[arrayOrder[3]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain4);stringfptrain5=ds.Tables[0].Rows[arrayOrder[4]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain5);stringfptrain6=ds.Tables[0].Rows[arrayOrder[5]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain6);stringfptrain7=ds.Tables[0].Rows[arrayOrder[6]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain7);stringfptrain8=ds.Tables[0].Rows[arrayOrder[7]-1]["file_path"].ToString();this.pictureBox8.Image=Image.FromFile("E://character_whole//"+fptrain8);特别蠢的显示。。

这代码写的,估计是复制粘贴出来的吧?从stringfptrain2=ds.Tables[0].Rows[arrayOrder[1]-1]["file_path"].ToString();下面的这个picturebox改改名字就好了。第二到第七都是pictureBox1,只有第八个对了,当然只显示两个了。
解决方案十一:
引用9楼mjp1234airen4385的回复:

Quote: 引用3楼lina181的回复:
Quote: 引用1楼wanghui0380的回复:
代码贴出来没代码的情况,个人估计是loction位置覆盖了当然我个人建议使用FlowlayeroutPanel,代替普通panel,这样就无需考虑location的位置了,只管control.add就是

stringfptrain1=ds.Tables[0].Rows[arrayOrder[0]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain1);stringfptrain2=ds.Tables[0].Rows[arrayOrder[1]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain2);stringfptrain3=ds.Tables[0].Rows[arrayOrder[2]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain3);stringfptrain4=ds.Tables[0].Rows[arrayOrder[3]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain4);stringfptrain5=ds.Tables[0].Rows[arrayOrder[4]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain5);stringfptrain6=ds.Tables[0].Rows[arrayOrder[5]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain6);stringfptrain7=ds.Tables[0].Rows[arrayOrder[6]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain7);stringfptrain8=ds.Tables[0].Rows[arrayOrder[7]-1]["file_path"].ToString();this.pictureBox8.Image=Image.FromFile("E://character_whole//"+fptrain8);特别蠢的显示。。

这代码写的,估计是复制粘贴出来的吧?从stringfptrain2=ds.Tables[0].Rows[arrayOrder[1]-1]["file_path"].ToString();下面的这个picturebox改改名字就好了。第二到第七都是pictureBox1,只有第八个对了,当然只显示两个了。

正解
解决方案十二:
引用10楼clxcxx的回复:

Quote: 引用9楼mjp1234airen4385的回复:
Quote: 引用3楼lina181的回复:
Quote: 引用1楼wanghui0380的回复:
代码贴出来没代码的情况,个人估计是loction位置覆盖了当然我个人建议使用FlowlayeroutPanel,代替普通panel,这样就无需考虑location的位置了,只管control.add就是

stringfptrain1=ds.Tables[0].Rows[arrayOrder[0]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain1);stringfptrain2=ds.Tables[0].Rows[arrayOrder[1]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain2);stringfptrain3=ds.Tables[0].Rows[arrayOrder[2]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain3);stringfptrain4=ds.Tables[0].Rows[arrayOrder[3]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain4);stringfptrain5=ds.Tables[0].Rows[arrayOrder[4]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain5);stringfptrain6=ds.Tables[0].Rows[arrayOrder[5]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain6);stringfptrain7=ds.Tables[0].Rows[arrayOrder[6]-1]["file_path"].ToString();this.pictureBox1.Image=Image.FromFile("E://character_whole//"+fptrain7);stringfptrain8=ds.Tables[0].Rows[arrayOrder[7]-1]["file_path"].ToString();this.pictureBox8.Image=Image.FromFile("E://character_whole//"+fptrain8);特别蠢的显示。。

这代码写的,估计是复制粘贴出来的吧?从stringfptrain2=ds.Tables[0].Rows[arrayOrder[1]-1]["file_path"].ToString();下面的这个picturebox改改名字就好了。第二到第七都是pictureBox1,只有第八个对了,当然只显示两个了。

正解

噗!!!谢谢大神!本来准备改数组的!!!!真是想拍自己脑袋3q!!!!

时间: 2024-08-01 07:57:28

C# picturebox好几个不能完全显示的相关文章

C#WINFROM的PicTureBox控件,可以显示AI图么?如果,可以应该怎么写?

问题描述 跪求答案,百度找不到. 解决方案 解决方案二:需要你自己解析文件了,或者找个控件,dll之类的东西,不直接支持解决方案三:图呢,你这个问的问题不详细啊解决方案四:不详细么?我就是想在PicTureBox控件里显示AI图,我现在不知道可不可以,如果你们接触过的话,请告诉我行不行,可以显示的话,请把详细的代码给我.谢谢!!!!

在初始化一个窗口时,pictureBox中初始化画图不显示

问题描述 如下面的初始化代码所示,在界面上添加了一个pictureBox的控件,想在上面初始化画图,运行不显示所画的图片.publicGraphicsg1;publicForm1(){InitializeComponent();g1=pictureBox1.CreateGraphics();g1.DrawRectangle(newPen(Color.Red),10,10,20,20);Penp=newPen(Color.Red,2);//定义了一个蓝色,宽度为的画笔g1.DrawLine(p,1

C# PictureBox加载图片并显示进度条

  以前用winform的PictureBox时没有试过加载网络的图片,刚刚看到一段代码才了解到原来还有LoadAsync这个方法,可以异步加载图片,再加上LoadProgressChanged事件也可以获得当前加载的进度. 在窗体上放一个PictureBox控件,一个按钮,一个进度条控件,再用Label来显示当前进度百分比,具体代码如下: private void button1_Click(object sender, EventArgs e)         {             t

VB 子窗体被PictureBox控件挡住无法显示

1.问题描述         VB做机房收费系统的时候,用的MDI主窗体,在主窗体上加了一个Picturebox控件,运行的时候,点了子窗体,但是却没有出现,后来才发现,子窗体被Picturebox控件给当在了后面.   2.问题原因      在MDI程序中,子窗体实际位于MDIClient里,就是说,子窗体的父窗体是MDIClient,而PictureBox和MDIClient属于同一级的    层次结构    ThunderMDIForm-MDIForm1    --MDIClient  

vb.net的PictureBox控件

PictureBox(图片箱)控件被用来显示图形,可以作为其他控件的容器.PictureBox控件在工具箱中的图标如图所示: 1.支持的图形格式 PictureBox控件可显示下述任何格式的图片文件:位图.图标.图元文件.增强型图元文件.JPEG或GIF文件.2.将图形加载到Picture控件中 在设计时,从"属性"窗口中选定并设置Image属性就可将图片加载到PictureBox控件中,也可在运行时设置PictureBox控件的Image属性: PictureBox1.Image=I

winform-VS2010 Winform 一个关于头像显示的问题

问题描述 VS2010 Winform 一个关于头像显示的问题 VS2010 Winform中如何在主窗口中显示登录用户的头像?头像如何存入数据库中,又怎么绑定给PictureBox控件呢? 解决方案 http://www.blogjava.net/AndyZhang/archive/2011/09/08/358267.htmlhttp://blog.csdn.net/wanglei_samrtfish/article/details/7438923 解决方案二: 头像一般以图片格式存在,存入数

C#picturebox的路径问题

问题描述 我写了一个获取路径的方式,将它变为string类型,但是运行时提示验证文件是否存在于指定位置.如果是直接将fptest的值写到文件路径中是可以获取的.请问是哪里出错了?具体代码为:stringfptest=ds.Tables[0].Rows[0]["file_path"].ToString();this.pbTest.Image=Image.FromFile("E:\fptest"); 解决方案 解决方案二:ds.Tables[0].Rows[0][&qu

vb的属性、方法和事件(四)

使用ScrollBar作为输入设备 滚动条通常与TextBox或窗口一起使用,但有时也可作输入设备.因为ScrollBar控件可按比例指示当前位置,所以可以单独使用以控制程序输入,如控制声音音量或调整图片颜色.HScrollBar(水平)和 VScrollBar(垂直)控件是独立的,它有自己的事件.属性和方法集.ScrollBar 控件与附属于TextBox.ListBox.ComboBox 或 MDI 窗体的内部 ScrollBar 不同.(TextBox 和 MDI 窗体具有 ScrollB

C#特殊类型窗体制作:实现类似Windows XP的程序界面

思路: 2到3个 pictureBox 控件, 控制是否显示并确定显示的坐标. 截图: 上传较慢, 效果类似于 windows XP 左侧导航界面 如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespa