❔ ComboBox event help
I'm currently making a Voting System for a school project and here's something I wanted to make for my own
So I wanted to be able to select the number of candidates in this form, make the unneeded options based on the selection automatically turn into "N/A" and make them unable to be edited. Thanks in advance!
10 Replies
$ask
How to get the best help
Make a post in #help or one of the topic channels under Development.
Avoid asking Can anybody help Has anyone used Why doesn't my code work?
C# is a big area! No one knows they can help unless you tell them about the small area you're trying to work in.
Explain what you are doing, and potentially why for as much context as possible. Avoid screenshots where possible, share code directly in Discord. Type
$code
into chat to learn how to post code.
See https://www.nohello.net and https://dontasktoask.com if you want common help chat room etiquette.Please share code as well as the GUI framework you are using
I'm using .NET framework, the code aside from the keypresses and unrelated buttons is yet to be added but I'm looking to achieve this specific task for this form to be functional.
the combo box for the number is called cboxCandidateNum and the rest is cboxCandidate1, cboxCandidate2, etc.
the simplest solution is to subscribe to the SelectedIndexChanged event on your number of candidates combobox, then depending on the selection index, if it's too low then set cboxCandidate2/3/4/5's text to N/A and set their Enabled property to false. if it's within range then set to true and reset the text.
that's the jist of it, if you want to write a clean solution to this, think about how a helper function could help here! :)
I'm using .NET framework,This is not a GUI Framework It is the runtime which is unrelated to the GUI Framework GUI Frameworks such as: - Windows Forms - WPF - WinUI3 .. etc.
I know this is not what you're asking for, but I feel like it would be easier to just let the user add candidates as needed
Ah, I reconsidered and I'm just gonna do that instead
did you get it working?
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.