Winform中怎样从image中读取图片到PictureBox

勾留WY 2017-08-21 10:16:16
switch (ds.Tables[0].Rows[0]["CakeName"].ToString())
{
case "水果蛋糕":
txt_kind.Text = ds.Tables[0].Rows[0]["CakeName"].ToString();
txt_Size.Text= ds.Tables[0].Rows[0]["CakeSize"].ToString();
break;
case "鲜奶油蛋糕":
txt_kind.Text = ds.Tables[0].Rows[0]["CakeName"].ToString();
txt_Size.Text = ds.Tables[0].Rows[0]["CakeSize"].ToString();
break;
case "巧克力蛋糕":

txt_kind.Text = ds.Tables[0].Rows[0]["CakeName"].ToString();
txt_Size.Text = ds.Tables[0].Rows[0]["CakeSize"].ToString();
break;
case "镜面蛋糕":

txt_kind.Text = ds.Tables[0].Rows[0]["CakeName"].ToString();
txt_Size.Text = ds.Tables[0].Rows[0]["CakeSize"].ToString();
break;
default:
break;
...全文
294 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
勾留WY 2017-08-21
  • 打赏
  • 举报
回复
想要看怎么动态添加的问题很简单只需要自己直接添加一个,然后看他的design.cs文件就可以直接知道了
全栈极简 2017-08-21
  • 打赏
  • 举报
回复
参考:
  IDictionary<string, object> dic = new Dictionary<string, object>();
                dic.Add("bh", bh);
                Bitmap bitmap = cardHelper.GetZP(dic);
                this.pictureBox1.Image = bitmap;
/// <summary>
        /// 根据条件查询照片
        /// </summary>
        /// <param name="dic">查询条件封装的字典</param>
        /// <returns>照片Bitmap</returns>
        public Bitmap GetZP(IDictionary<string, object> dic)
        {
            string sql = "select * from xxb where 1=1 ";

            if (dic.ContainsKey("bh"))
            {
                sql += " and id = " + Convert.ToInt32(dic["bh"]) + "";
            }
            if (dic.ContainsKey("xm"))
            {
                sql += " and 姓名 = '" + Convert.ToString(dic["xm"]) + "'";
            }
            if (dic.ContainsKey("sfzh"))
            {
                sql += " and 证件号码 = '" + Convert.ToString(dic["sfzh"]) + "'";
            }

            using (IDataReader odr = accessOp.ExecuteReader(sql))
            {
                if (odr.Read())
                {
                    if (!string.IsNullOrEmpty(odr["照片信息"].ToString()))
                    {
                        byte[] bytes = (byte[])odr["照片信息"];

                        using (MemoryStream ms = new MemoryStream(bytes) { Position = 0 })
                        {
                            return new Bitmap(ms);
                        }
                    }
                }
            }
            return null;
        }
全栈极简 2017-08-21
  • 打赏
  • 举报
回复 1
无语... csdn有黑名单功能吗?

111,093

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧