C
C#17mo ago
Diesel Geezer

❔ How to Initialize different forms using same piece of code

I have this piece of code and i want to use it for different forms. In this case i can't initialize the form directly using its name like `customForm frm = new customForm();' and i tried using the 'Form' class which is more general. Problem is that initializing forms using the 'Form' class does not work properly. How can i make this function work with different classes?
8 Replies
canton7
canton717mo ago
You probably want Form form = new CustomForm()?
Diesel Geezer
Diesel GeezerOP17mo ago
No that won't work. I want this function to work with multiple forms, not just one, like customForm
canton7
canton717mo ago
Why won't that work exactly? I'm a little confused by the code in your question. I'm not sure what it's trying to do -- is it trying to show a form, or create one? If it's trying to create one, why are you passing one in?
Diesel Geezer
Diesel GeezerOP17mo ago
Its trying to create form and if it already exists, just show it. I am passing the form that i want to create/show
HimmDawg
HimmDawg17mo ago
So basic question: You only want one placeholder for a form which can be filled with any of those 5 forms? Or do you want to be able to hold 5 placeholders, one for each form and check against those?
Diesel Geezer
Diesel GeezerOP17mo ago
The first one
HimmDawg
HimmDawg17mo ago
Well you cannot overwrite frm in your method of course. You need to have some placeholder outside of the method to preserve a form
Accord
Accord17mo 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