Jump to content

How would I go about dynamically adding buttons or any other object into a C# Forms Application?

Ok, So I thought of an idea of having a button create a new button dynamically, which would give it a new name and put it into a listbox which you would be able to edit the size and location of the buttons as well as delete them too. Any ideas how I would be able to go about doing something like that? I got the idea from looking at how you can dynamically add stuff in basically any editing program. Like how in photoshop you can add a new layer and it will pop up with a name like "layer1" then "layer2" and so on then you can do stuff with the object and delete them... But doing it in a C# Forms Application and using Buttons or any other object like a picturebox or a panel.

Link to comment
Share on other sites

Link to post
Share on other sites

This is possible in WinForms but it's far from pleasant. Why not use WFP and the MVVM design pattern? While being the more modern approach it also makes this kind of thing trivial.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×