Solved

c# winforms class to display 'please wait'

Posted on 2013-06-13
6
3,766 Views
Last Modified: 2013-06-13
Hi

I am trying to create a class that displays a message in a panel which is centered on the screen... a simple 'please wait' would be fine, so that I can call something like

busy()

to display the message no matter what form is open in the application...

Any ideas how I get this to work?

Cheers

CD
0
Comment
Question by:cycledude
  • 3
  • 3
6 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 39246691
Basically just how you described it.  Just use the .Show() method to show the window - that does not wait at that point.  In the form properties there is a setting for it to display centrally.

eg.
MyWaitForm frm = new MyWaitForm();
frm.Show();
....  //your code goes here
frm.Close();
0
 

Author Comment

by:cycledude
ID: 39246703
ah i see, so create a form with the message in it and then display the form...
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 39246711
Yes - or you could even pass a message into the form if you wanted different messages from the default you supply.

MyWaitForm frm = new MyWaitForm();
frm.DisplayMessage("Hello");
frm.Show();
....  //your code goes here
frm.Close();

in the form
public void DisplayMessage(String s)
{
  this.MessageLabel.Text = s;  //MessageLabel is the control you display the 'Please Wait' in
}
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:cycledude
ID: 39246725
so simple

I was thinking of creating a class, which created a panel in code then added a label and an image, then set the message... but this is way easier.. thanks
0
 

Author Closing Comment

by:cycledude
ID: 39246726
;o)
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 39246751
The trick is the .Show() so it doesn't block the code.  However it does require you to close the form from code yourself.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question