100分求助:Winform下如何浏览SQL数据库中里的图片? 我现在已经能够将数据库中的图片显到PictureBox控件中,可是数据库里有很多图片,我需要对图片进行单张或多张浏览,这样pictureBox的个数是不定的,该如何定义pictureBox对象啊?并且这还设计到图片的缩放问题。有人说:用一个PictureBox 多个Image对象也可以完成,可是具体该如何操作啊?我是新手,请各位高手多多帮助我!给点思路也行! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 动态生成pictureBox比如用模板。 qugui(阿贵)你好,你说用用模板动态生成pictureBox,可以详细给一些代码吗,谢谢!这是我的,你看,我定义了很多pictureBox:private System.Windows.Forms.PictureBox pB1; private System.Windows.Forms.PictureBox pB2; private System.Windows.Forms.PictureBox pB3; private System.Windows.Forms.PictureBox pB4; private System.Windows.Forms.PictureBox pB5; private System.Windows.Forms.PictureBox pB6; private System.Windows.Forms.PictureBox pB0;using(SqlConnection m_connConnection = new SqlConnection(m_strConnString)) { m_connConnection.Open(); SqlCommand mycmd=m_connConnection.CreateCommand(); mycmd.CommandText="select * from upimage"; SqlDataReader dr = mycmd.ExecuteReader(); int i = 0; while(dr.Read()) { i += 1; byte[] bytes = (byte[])dr["upimage"]; MemoryStream ms = new MemoryStream(bytes); Image img = Image.FromStream(ms,true); PictureBox pic = GetPictureBoxByName("pB" + i.ToString()); if (pic != null) { pic.Image = img; } ms.Close(); } } 从数据库提取数据,在网页上显示是很明显的思路<asp:HyperLink runat="server" ID="hlItem" NavigateUrl='<%#"viewalbum.aspx?id="+DataBinder.Eval(Container.DataItem,"id")%>'> sillybirdustc(笨笨鸟),你好,我的难点是如何动态生成pictureBox,并且控制图片的大小 我放了Panel后,动态生成pictureBox看不见了,动态生成pictureBox如何在PANEL中置于顶层啊? 没有人知道吗?我加了picArray[i].BringToFront();也没有用啊!项目很紧,请大家帮助我! 谢谢lovewindy(LOVE风云),我现在已经可以实现用pictureBox动态加载了,可是如何使加载的图像居中啊?? 如何使treeview不同的节点显示不同的图标 byte[]转化成string C#格式化时间问题 [Vista下装vs2008]为什么总是提示文件错误 懂Microsoft Visual Studio .NET 2003的进来一下. 一个关于dataTable的问题,请大家帮忙 不是很难的问题,datagrid.在线等答案 有高手熟悉DTS的API吗? debug一个C#的程序,如何在调试的时候能看到对应的MSIL汇编代码? 寻求C#语言访问数据库操作 winform中数据更新问题 有谁知道install shield 9.0 的用法啊
比如用模板。
这是我的,你看,我定义了很多pictureBox:private System.Windows.Forms.PictureBox pB1;
private System.Windows.Forms.PictureBox pB2;
private System.Windows.Forms.PictureBox pB3;
private System.Windows.Forms.PictureBox pB4;
private System.Windows.Forms.PictureBox pB5;
private System.Windows.Forms.PictureBox pB6;
private System.Windows.Forms.PictureBox pB0;
using(SqlConnection m_connConnection = new SqlConnection(m_strConnString))
{
m_connConnection.Open();
SqlCommand mycmd=m_connConnection.CreateCommand();
mycmd.CommandText="select * from upimage";
SqlDataReader dr = mycmd.ExecuteReader();
int i = 0;
while(dr.Read())
{
i += 1;
byte[] bytes = (byte[])dr["upimage"];
MemoryStream ms = new MemoryStream(bytes);
Image img = Image.FromStream(ms,true);
PictureBox pic = GetPictureBoxByName("pB" + i.ToString());
if (pic != null)
{
pic.Image = img;
}
ms.Close();
}
}
<asp:HyperLink runat="server" ID="hlItem" NavigateUrl='<%#"viewalbum.aspx?id="+DataBinder.Eval(Container.DataItem,"id")%>'>