图片框可见属性不起作用...帮助请 [英] PictureBox visible property does not work... help please

查看:116
本文介绍了图片框可见属性不起作用...帮助请的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的窗口应用程序和C#..我有一张照片是在应用程序..点击一些按钮时开始看不见,图片框已被显示。



我用这个编码,但图片框是不可见的。

 私人无效save_click(对象发件人,EventArgs E)

{

pictureBox1.Visible = TRUE;
pictureBox1.Show();

//做的工作在这里
//存储和datadase

pictureBox1.Visible = FALSE retreiving值;
pictureBox1.Hide();
}



PS ..在图片框中我显示一个GIF ..所以用户会知道一些工作在后台.. $ b $打算在b上这将需要很长时间才能完成......


解决方案<功能/ DIV>

假设保存到数据库中需要一些时间,你应该异步用做的BackgroundWorker ,隐藏你的图片框一次操作完成。



这是图像不显示当前的原因是因为当你长时间运行的保存操作时,Windows消息没有被处理,所以你的形式将响应用户输入而不是进行重新绘制。当保存操作完成后,和消息开始被再次处理,图片框已经被再次隐藏。


I am using window app and C#.. i have a picture which is invisible at the start of the app.. when some button is clicked, the picture box has to be shown..

i use this coding but the picture box is not visible

private void save_click(object sender, EventArgs e)

{

      pictureBox1.Visible = true;
      pictureBox1.Show();

      //does the work here 
      //storing and retreiving values from datadase

     pictureBox1.Visible = false;
     pictureBox1.Hide();
}

P.S... in the picture box i am showing a gif.. so the user will know that some work is going on in the background.. It will take long time for the function to finish...

解决方案

Assuming that the saving to the database takes some time, you should be doing it asynchronously using BackgroundWorker, hiding your PictureBox once the operation completes.

The reason that the image is not showing currently is because while your long-running save operation is occurring, Windows messages are not being processed, and so your form will be unresponsive to user input and not perform repaints. When the save operation finishes, and messages start being processed again, the picture box has already been hidden again.

这篇关于图片框可见属性不起作用...帮助请的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆