[英]Database image to background (windows form)
Hi i am new to windows form programming and having some trouble coding. 嗨,我是Windows窗体编程的新手,并且在编码时遇到了麻烦。
What i am trying to do is replace the current background of the windows form with another background that has been stored in my database. 我想做的是用存储在数据库中的另一个背景替换Windows窗体的当前背景。
cmd = new SqlCommand("select Background from Employee where EmployeeName='" + label2.Text + "'", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
MemoryStream ms = new MemoryStream((byte[])ds.Tables[0].Rows[0]["Background"]);
pictureBox1.Image = new Bitmap(ms);
These are the codes that I tried using a picturebox as the background, But unable to do so with the background. 这些是我尝试使用图片框作为背景的代码,但是无法使用背景来实现。 Any form of help is much appreciated 非常感谢任何形式的帮助
this.BackgroundImage = new Bitmap(ms); this.BackgroundImage =新的Bitmap(ms);
Note: This will present the image using the BackgroundImageLayout property setting (eg. - None, Center, Stretch, etc.). 注意:这将使用BackgroundImageLayout属性设置(例如-无,居中,拉伸等)显示图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.