我使用的窗口应用程序和C#..我有一张照片是在应用程序..点击一些按钮时开始看不见,图片框已被显示。
我用这个编码,但图片框是不可见的。
私人无效save_click(对象发件人,EventArgs E) { pictureBox1.Visible = TRUE; pictureBox1.Show(); //做的工作在这里 //存储和datadase pictureBox1.Visible = FALSE retreiving值; pictureBox1.Hide(); }
PS ..在图片框中我显示一个GIF ..所以用户会知道一些工作在后台.. $ b $打算在b上这将需要很长时间才能完成......
解决方案假设保存到数据库中需要一些时间,你应该异步用做的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.
更多推荐
图片框可见属性不起作用...帮助请
发布评论