I'm developing a C#.NET (4.0) WinForms application. On startup I want to have a splash screen that fills a series of datagridviews on a different form.
At the moment the main form loads that data into the DataGridViews on Form_Load but this makes the Form hang there while this is happening.
So how do I call the method that loads the values to the DataGridView from the splash screen?
I'm rather new to C#.NET, I'm trying to move away from VB.
I would have the splash screen launch the real form where the DataGridViews are, and in that form put the data loading method on its own thread. For a nice and simple and beginner way, use a BackgroundWorker. For more advanced control use Threading.
How to use background worker.
Threading Class Docs
Very good tutorial on threading
EDIT:
As you mentioned in your comment it sounds like you still don't want the form to even appear until its done loading in the data. The easy way to do this is have the main form be hidden from startup, and in the on-load event launch the splash screen, and then when the method that does the data loading returns, set the visibility to true and close the splash screen form.
There are many ways to have a form start hidden. Here is a good forum question with lot of answers on different ways to do it.
Related
I have an app that uses a Splash Screen when it opens up, and it works fine.
The problem is that I've added a couple of pages that can be accessed via two live tiles, and the point is to let the user istantly load a certain section of the app without having to load the whole MainPage.xaml page, which is quite heavy to load.
These two pages are really simple and load almost istantly, but the app loads the Splash Screen anyways, and I don't like that.
Is there a way to "disable" the splash screen for a specific page?
Via C# or directly from the XAML, I don't know.
I enabled the Splash Screens simply by adding the SplashScreenImage.screen-WXGA.jpg (720p and 1080p as well) to the project main directory.
Thanks! :)
Sergio
No. You can't disable the splash screen. What you can do is to minimize all initialization work your app has to do so that the splash screen is shown for a minimum of time.
Sergio,
You can simulate a splash screen and decide based on how you were activated to show it or not. This sample shows one way to do it: https://code.msdn.microsoft.com/windowsapps/Splash-screen-sample-89c1dc78/
I would show it for the main xaml and others that take a long time to load and dismiss it in code.
I have a MDI form on which I have a menu, Sidebar and somewhat around 50 More controls which makes my application interface very heavy. Also I am loading something around 500 user data which is also loading on my MDI form List box.
However all these process takes a lot of time to load, what I want to do is to load all the stuff just before displaying my MDI form.
Lets say, when I click on login, It should show a progress bar and when progress bar loads to end with all the configuration like "User List Display, Loading of controls and other settings": Then only MDI form should appear.
I have also gone through the DevExpress control:
Splash Screen: http://documentation.devexpress.com/#WindowsForms/CustomDocument10826
Splash Screen video: http://www.youtube.com/watch?v=mFl6P9I6c5A
But this is proprietary.
Is there any control available with winforms so that I can accomplish it.
Like the way we use to see with Visual Studio, Photoshop and other softwares which are very heavily build.
Also, what would be the ideal way of doing this. I have read a lot about, backgroundWorker and Threading. Just need advice on what would be the best way as per you guys. And yes, the smartest way.
I am working on a project that simulates a company's program for performing various functions within a GUI (using C# on VS2010). Currently there are about 10 or so different forms, one for each function (serving as a menu, filling out assorted forms, management of said forms, ect). So far we've been using things along the line of:
Form1 myForm1 = new Form1();
myForm1.Show();
to open new screens and
this.Hide();
when finished with the currently active form. (this.Close() just seems to close the entire program)
This causes some issues in that the process has an issue of continuing to run after the X at the top right of the form is clicked (I think that this is due to hidden forms not being closed properly). I also suspect that if a user uses in-program navigation without killing the process long enough, the constant generation and hiding of forms will end up hogging up all the memory.
In the wild, I rarely see programs that rely on opening new windows/forms constantly to enable user navigation. Programs, such as an installer, typically use an event of some sort to cause the current displayed content to disappear and new content to appear without changing to a new form/window. How can I go about doing this? Is it a matter of having buttons/textboxes/labels all stacked on each other in the one screen, but hidden or is there something more intuitive that I am missing?
Have you looked in to using some kind of MDI setup: http://www.codeproject.com/Articles/7571/Creating-MDI-application-using-C-Walkthrough
The way you can do this (but isn't always feasible) is to make a UserControl for each screen. When its time to move on to the next screen, you simply hide the current user control and show the next one. So if you have 8 screens for example, you make each one into a user control.
Then on your MainForm's Load event, you initially hide all except the first one. When its time to move onto the second screen, you hide the first control and show the second, etc etc
I would like to use a regular window for splash screen, so no PNG splash screen but a normal window where I can add some bitmaps on.
What is the best way: to keep in app.xaml the loading of the main screen and put the splash screen in the constructor or somewhere in an event handler?
The splash scren itself is quite easy, just has some labels, a link, a few images and just waits a few seconds before closing, no actions to be done while waiting.
Specifically for a splash screen, it is very important to make use of the functionality introduced in .NET 3.5 for this purpose. If you simply use a vanilla Window it can take quite some time for the WPF stack to initialize, and in the interim the user will not be seeing any feedback for their "launch the app" action.
Of course this does not satisfy the requirements of the question ("use a regular window"), but if it's not acceptable I would recommend using an different technology than WPF entirely because of the problem mentioned above.
I have myself designed my WPF app dynamic splash screen in which there was an animation, dynamic software Number which changed for each and every software, a label which was updated every 1/2 ms to show some random filename in the sofware directory.
To be frank i used this link to create mine
http://www.codeproject.com/Articles/38291/Implement-Splash-Screen-with-WPF
There are other links which i can provide you
http://www.codeproject.com/Articles/116875/WPF-Loading-Splash-Screen
http://www.olsonsoft.com/blogs/stefanolson/post/A-better-WPF-splash-screen.aspx
I'm going to input a splash screen to an application I'm currently working on that only consists of one form which we will call frmMain for now. I want to implement a splash screen (frmSplash) but need advice as to what would be the best way to implement it. The purpose of the splash screen will be to load necessary settings into textboxes, checkboxes, etc. based on the last settings of when the program was last closed. Here's my question.
Should I let the main form load, but keep it invisible to the user and then call the splash screen which will run and then load all the settings into the main form?
If so how would I do the above? Load the frmSplash in the frmMain_Load event? I plan to keep the splash screen visible for at least 3 seconds. How would I give it the pause effect so that it stays up for 3 seconds while it recovers the settings from the settings file?
Yes, it is a good practice to use a splash screen to hide form initialization. Here is a pretty good tutorial that should get you up and running:
Creating a Splash Screen in C#
It's probably cleaner not to load the settings in the splash form, but to keep that just for display. Display the splash form and load the settings in the main form.
I would suggest going the other way. Have frmSplash start up, parse the settings and pass them on to a new hidden frmMain. And once frmMain has finished loading (or after 3 seconds) show it.
Or just have the splash screen create a hidden frmMain and show it once it's done loading and in a valid state.
There's an example here, and one with better explanations here.
Note that neither of these examples perform any kind of "pre-loading", but you can do all that in the main thread while the splash thread is doing its eye-candy work.
Hopefully this is the kind of thing you're looking for. Good luck!
Here's a canned version you can try: Autorun Action Splash