A question for my c# winforms project
hello guys,
i have a question about my c# winforms project.
So : I have 2 Projects the first Project is the Login and the second Project is my Dashboard, how can i do that the form from the second Project opens when the login is succesful.
3 Replies
1. Generally you use projects to isolate and/or share code between other projects. You don't want to make a separate "project" for every form you make. You can easily have multiple forms in the same project
2. Although hiding forms is an option, I would recommend constructing a login form, showing it, and then closing it, and then opening your main form (essentially don't keep the login form running but hidden in the background if not necessary). There can be issues when you do that, like when you show the logon form again it could be pre-populated with the previous credentials if you don't clear it. And if you don't clear it after logon, you have a hidden form with credentials in the background, and various apps and hackers could technically find the credentials throughout the user's session
3. I don't know what kind of project this is (school, educational, personal, etc.) but keep in mind that Winforms is considered a bit outdated and most people recommend other options if possible. But if you are still prototyping, nothing wrong with starting in Winfroms to prototype.
4. In order to use code from other projects you just add a "project reference" to your project. You can do that by right clicking the "Dependencies" under your project in Viosual Studio and choosing "Add Project Reference". That will add a project reference in your
.csproj
. If you are not using Visual Studio you can just add the reference directly in your .csproj
. But again... you don't want to make a new project for each form. that is overkill and unnecessaryWhat are you making?
TBH you have to push me pretty hard to make a new project. It needs to solve a technical problem, and usually new projects are used for organizational structure.