Re: Generic function to output the values of an Enumeration
- From: "Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Tue, 13 May 2008 12:11:55 -0700
On Tue, 13 May 2008 09:19:57 -0700, DotNetNewbie <snowman908070@xxxxxxxxx> wrote:
Hi,
I want to create a method that takes in the type of a Enumeration,
passes in the Enumeration as an object, and then outputs the values
with checkboxes, and pre-checks the checkbox if that value is set in a
mask.
This is what I have so far that outputs the values as a checkbox, but
I need to pass in *any* mask so it can check if that value is set in
the mask, if yes, check the checkbox.
What I would do is enumerate the Enum.GetValues() array instead of the GetNames() array. Cast your mask and current value to int, and set the checkbox based on that result.
You could of course parse the enumeration value name, going the other direction. But I think it reads better starting with the value, and I think that converting the value to a string (for use as the "name") is slightly easier than converting the string to a value (though neither is really that hard).
Pete
.
- Follow-Ups:
- Re: Generic function to output the values of an Enumeration
- From: DotNetNewbie
- Re: Generic function to output the values of an Enumeration
- Prev by Date: Re: Sub Form Cleanup
- Next by Date: Re: Best Way to Test Against a Database
- Previous by thread: Best Way to Test Against a Database
- Next by thread: Re: Generic function to output the values of an Enumeration
- Index(es):
Relevant Pages
|