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...
The PictureBox control is used for displaying images on the form. The Image property of the control allows you to set an image both at design time or at a runtime. Specifies whether the picture box accepts data that a user drags on it. Gets or sets the path or the URL for the image displayed in the control.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With