✅ how to do a "login screen" in winforms
i'm building out an app with winforms, and I want a "login screen" that appears on startup and basically locks out the "main app" until you've logged in, is this done using a separate Form? or just a dialog of some kind? what's the best way to tackle it?
12 Replies
base on which style you like . create a panel , switch to other panel. or create a new form, load a new form, after login
so, in the designer do I make a new UserControl? or add a Form? or can it be either?
it depends on your design
if you want to keep your app without opening new windows
you would use usercontrols as pages and swap as needed
either in panels or in the form it self
if u dont care then yes u could create a new window for login, pass the result back and open a new window for the app itself if the result was successful.
yeah i think i'm gonna go with the 2nd one. I"m guessing i'd need to rewrite Program.cs to open the login "Form" and then pass the result back?
i guess part of my issue is, what's the difference between "Form" and "Control" in the context of winforms?
I'm guess "form" is the top-level window? but it seems you can have more than one per app, whereas in other frameworks you can only have one
Form is a window kind of type UserControl is a control that can be used within the Form
which is often used to create custom pages, controls etc
and no most framworks have both
WPF for example have window and usercontrol, the name is more meaningful
MAUI has Shell and ContentPage( and a few others)
so the hierarchy goes like Form -> Panel -> Control?
Form > any other control
Panel is also a control
ahh ok
there are different types of panel which are often used for organizational purposes
like split panel so u can have a side menu and the content to the right of it for example
ok i think i get it now, thanks
$close
If you have no further questions, please use /close to mark the forum thread as answered