Re: Generic function to output the values of an Enumeration

Tech-Archive recommends: Speed Up your PC by fixing your registry



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
.



Relevant Pages

  • Re: Generic function to output the values of an Enumeration
    ... I want to create a method that takes in the type of a Enumeration, ... I need to pass in *any* mask so it can check if that value is set in ... the mask, if yes, check the checkbox. ... slightly easier than converting the string to a value (though neither is   ...
    (microsoft.public.dotnet.languages.csharp)
  • Library block with variable outputs
    ... I want to create a Simulink library block with a variable number of outputs. ... Therefor I have one parameter which is set in the block's mask via a checkbox. ... In addition I wrote a dialog callback for this parameter, which connects a line either to a terminator block or to an outport block, depending of the state of the checkbox. ...
    (comp.soft-sys.matlab)