C
C#•9mo ago
nkr

Windows Forms help needed

Hey guys! I'm building a school project in C# using Windows Forms. I really need some help in plenty of things. I'm completely unfamiliar with this. Here is the Form itself How do I achieve so if I choose a different menuitem on the top the context of the page changes? so for example if I click the 2nd option "Munkalap" the background is no longer visible but rather I can add new handles that I want on that page if someone is experienced in windows forms I would greatly appreciate if you'd hit me up or in general anyone answering here:)
No description
29 Replies
Hazel 🌊💃
I recommend using a tab control instead of a menu strip for that page change idea. It automatically handles that for you.
nkr
nkrOP•9mo ago
Thank you so much Decided to stick with ToolStripMenuItem because that's what my prof asked for.
nkr
nkrOP•9mo ago
When I press the second option "Munkalap" something like this should pop up
No description
nkr
nkrOP•9mo ago
how can I achieve this? for context: This is a car mechanic workshop and this page accumulated the total costs for repair
Pobiega
Pobiega•9mo ago
are all the menu items, supposed to open new windows like this? because thats not "changing the page" as you previously asked for
nkr
nkrOP•9mo ago
yes, that's right I didn't examine closely but all of them are supposed to open like this in new windows
Pobiega
Pobiega•9mo ago
okay each window (aka Form in winforms) will be its own class so when the button is clicked, you just create a variable for that form, instantiate it with the construtor, then call the .ShowDialog() method on the form
nkr
nkrOP•9mo ago
something like this?
nkr
nkrOP•9mo ago
No description
nkr
nkrOP•9mo ago
yes now I have the new windows popping up but how exactly do I put stuff in them to make it like this?
nkr
nkrOP•9mo ago
No description
Pobiega
Pobiega•9mo ago
by putting things in them? just as you did with your main form
nkr
nkrOP•9mo ago
yeah right, thank you
nkr
nkrOP•9mo ago
@Pobiega sorry for the ping, hope I don't bother you but could you please guide me a bit further? The goal is to get the "Munkalap" (you could call it "Worksheet") form to show the content of a Txt file that look something like this: ` Számítógépes hibakeresés;10;0 Téli/Nyári kerékcsere;30;0 ˙ in columns columns are separated with ";". Whenever I try to run the code everything works just fine but when I try to open the Worksheet form it doesn't show anything. here is the Worksheet method for dataload
No description
nkr
nkrOP•9mo ago
No description
nkr
nkrOP•9mo ago
and this is what I would like to achieve
No description
Pobiega
Pobiega•9mo ago
well, what you want to achieve certainly doesnt use a listbox in fact, it seems to use dynamically added controls of some sorts
nkr
nkrOP•9mo ago
are they labels?
Pobiega
Pobiega•9mo ago
looks like it, yes and then there is a checkbox
nkr
nkrOP•9mo ago
Can I update labels based on the txt file I provide? I want the labels to show up only that are in my txt file
Pobiega
Pobiega•9mo ago
yeah, but it will be a mess I suggest you create a user control
nkr
nkrOP•9mo ago
I’ll look into that thanks
Pobiega
Pobiega•9mo ago
Pobiega
Pobiega•9mo ago
then you can make something like this in this case I add them when you click the button, but it could easily be from a file instead to clarify, I created a user control that has 4 labels and a checkbox in it, all spaced up the way you want. When the button is clicked, a new usercontrol is instantiated and added to a FlowLayoutPanel
nkr
nkrOP•9mo ago
sounds like a good idea could you share your code please?
Pobiega
Pobiega•9mo ago
No. That would be cheating. I already spoonfed you a solution, but the implementation is up to you
nkr
nkrOP•9mo ago
Fair play Thanks for your help
Pobiega
Pobiega•9mo ago
Just to be clear, this doesnt mean you wont get more help here, I just won't hand you the code. If you get stuck, feel free to ask for more help
nkr
nkrOP•9mo ago
Appreciate you! I'll ask whenever I need
Want results from more Discord servers?
Add your server