Passing enumerators between forms

The different forms in my app use the name enumerators, thus it seems logical to put the enumerators in a class and then pass them to the forms that need them.  Can't quite figure out how to perform this.  I need to know how to pass the enumerations or iterate them from the class.  Any help appreciated.

V Whitehead
vaughnwhiteheadAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jacques Bourgeois (James Burger)PresidentCommented:
I suppose that you meant "same enumerators" instead of "name enumerators".

The best way would be to create constructors that receive the enumerator(s) as a parameter for the form that needs some. Simply add a New method that requires the proper parameter(s), and pass the enumerator(s) to the constructor when you instantiate your object. Doing so, you lose the standard constructor without parameters that is needed for the Form Designer to work, so you will need to add it also. Be sure to keep the call to InitializeComponents that the designer adds for you when you create a New method, this is necessary for the controls to show on the form.

This is the best way to do go, because only the forms that need them will have access to them. But it is not always possible to do so, because one form could be called by another one that does not have access to the required enumerator(s).

In such a case, Declare the enumerators in a module, as Public variables. A module is the way, in VB.NET, to have information available everywhere in the application. See it as a static class if you know the concept from another language. Once instantiated, Public variables in a module are visible everywhere in the Project simply by calling their name.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
käµfm³d 👽Commented:
By "enumerators" do you mean enums or actual enumerators?
0
vaughnwhiteheadAuthor Commented:
Thanks,

Both solutions worked fine, I guess that I will go with the module, as some of the forms will need up to 8 different enums, and I don't want to pass that many to a New constructor.
Again thanks

V Whitehead
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.