I have around 15 forms and every form includes some similar piece of codes.
What i want to know is that there is any way to automatically call a function containing that particular piece of code when a form is opening?
Like, lets say i want to show Hello World message every time when any form of a project is loaded.
So what i can do is i can create a module or class file and i can add a piece of code their and i can call it in every form.
But this i don’t want, what i want is that, is there any way where i can add this piece of code and automatically it gets populated/triggered when a form gets loaded.
Maybe we can call it something like – auto calling function for forms
Like, whenever a form is opening automatically a class or function gets called without defining it in the particular form. Maybe a library kind of thing which will be called anyways when a form is loaded and i can add my piece of code there and it gets executed.
Create your own base class inheriting from form:
Then every form you are using may inherit from this base class: