27 Replies
i reached limit
cs
not C#
after the backticks
and break it up if its too long, or use $pasteIf your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
ok wait
noone wants to download a .txt file just to read your code
BlazeBin - hrwavucnckji
A tool for sharing your source code with the world!
sorry here it is
Okay, there is a whole pile of wrong here
First: don't open new forms in another forms constructor. Especially not your main form.
two:
This will open a new form to then immediately close it again
yeah i tried doing .Close() but it dont work for the loginWindow
i can only close it from Main
um
why
Because the main form isnt fully constructed at that point
but it will construct right after Login is closed right
yes, in theory - but with winforms (and probably also WPF) the main form is treated differently
it sounds like you should just hide the main form, create and show a login form once the main form has loaded (with the load event), then when the login form is done you can show the main form again
HOWEVER
this code:
will never work as you want
after show, it will not "stop" to wait for you to finish logging in. it will instead move to
.Close
and close
If you want the main forms code to "wait" for the login, you need to use ShowDialog()
and then you also dont need to close it yourselfyes i used this ShowDialog() but the thing is the login window wont close unless i press the close button for it
i wanted for it to close when the user presses the button for which
AttemptLogin
runsAnd that can be done.
if you give your button a DialogResult value
um
how do i do that
step 1: add a Loaded event handler to your main form
in LoginWindows.xaml
what is thiss
before i could even test this suddenly happened ðŸ˜
your program is already running
close it before starting a new one
yoo its fixed noww
thank youu
@MementoMori tip, wpf does not work like winform u should learn MVVM and how to navigate instead of opening new window
https://www.youtube.com/watch?v=N26C_Cq-gAY&list=PLZnwzjShc0PS1DDfPTW3oLSTsn878a6_P&index=22
might be a bit overwhelming at first for u, since ur new to it.
i will check it out thank you