✅ 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
mikuno01
mikuno012d ago
base on which style you like . create a panel , switch to other panel. or create a new form, load a new form, after login
enrico11011
enrico11011OP2d ago
so, in the designer do I make a new UserControl? or add a Form? or can it be either?
leowest
leowest2d ago
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.
enrico11011
enrico11011OP2d ago
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
leowest
leowest2d ago
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)
enrico11011
enrico11011OP2d ago
so the hierarchy goes like Form -> Panel -> Control?
leowest
leowest2d ago
Form > any other control Panel is also a control
enrico11011
enrico11011OP2d ago
ahh ok
leowest
leowest2d ago
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
enrico11011
enrico11011OP2d ago
ok i think i get it now, thanks
leowest
leowest2d ago
$close
MODiX
MODiX2d ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?