❔ Programmatically created buttons - Editing WinForms

Hello, I have a winform that pulls from a database to determine what buttons are loaded for a user. https://pastebin.com/5AEs0Z5P This creates a user control (that is a button and some simple labels) that will be put into a flowlayout and generated like a list. C# Makes WinForms public partial classes and thus I cannot manipulate the winform with the user control (or vice versa). How can I get around this? I would like the user control to edit the form onclick. My but my onclick statement cannot see anything on the form. I have also attempted to created an event listener that gets generated with the button, but on the main winform, however this event never runs. This leads me to believe that due to the public partial class the events from a usercontrol cannot be seen by the main winform even if they exist on the same winform. https://pastebin.com/CkCE7uBc Is there a way to get around this?
Pastebin
Button Creation - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin
DoubleDown - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
3 Replies
mrphil2105
mrphil21052y ago
I'd suggest not using WinForms and use WPF which has the ItemsControl which is perfect for a list of controls based on list of data.
spicymemedragon
Can do. I am over all the issues with winforms
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server