C#C
C#3y ago
3 replies
spicymemedragon

❔ 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?
Cap1.PNG
Cap2.PNG
Pastebin
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
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.
Was this page helpful?