Reputation: 5539
I have a windows form with several labels and buttons. Eg:
Name : ____
Age : ____
Phone: ____
btnCancel | btnModify
The values of the labels (____) are fetched from database on page load. When I open this form labels such as Name,Age,Phone get loaded first, then ____ get updated when query returns result, and then btnCancel and btnModify get displayed. I want entire form to load at once when the value have been fetched. It would also be great if I could give some kind of indication that system is processing.
Upvotes: 0
Views: 1218
Reputation: 3257
You could put all of the controls into a "panel" and then set the Panel.Visible to false and when the load and update are complete set the Panel.Visible to true.
The easiest way to signal a busy state is to use Control.UseWaitCursor property. You should be doing the actual loading in another thread.
For example, inside a Form or a UserControl:
panel1.Visible = false;
this.UseWaitCursor = true;
Task.Run(() => {
var data = LoadTheData();
this.BeginInvoke((Action)(() =>
{
labelName.Text = data.Name;
panel1.Visible = true;
this.UseWaitCursor = false;
}));
});
Upvotes: 1