Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am using this code for display image while retrieve data from database to DataGridView in C# .net windows application.:-

C#
pictureBox1.Visible = true; // it's a swf loading image.
dataGridView1.ReadOnly = true;
SqlConnection con = new SqlConnection(cnString1);
con.Open();
dadapter = new SqlDataAdapter("select * from BAN_ItemDataMaster where [Signal Code]='HOME'", con);
data = new DataTable();
dadapter.Fill(data);
dataGridView1.DataSource = data;
con.Close();
pictureBox1.Visible = false;


But my code doesn't run properly.
My image did not display.

I want to display image while database load.

Please help me, How could be possible?

Thanks in advance.

Ankit Agarwal
Software Engineer
Posted
Updated 8-Sep-13 23:37pm
v2

1 solution

The interesting part is between PictureBox1.Visible = true;
and PictureBox1.Visible = false;.

It's all running in the main thread (a.k.a. GUI thread). Therefore GUI thread doesn't have time to repaint the GUI, which is its main duty.

Separate out the database stuff to another thread, so that GUI thread can display (and later hide) PictureBox1.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900