Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm still quite new to vb.net and I have just come across enum whilst using a third party software.

 

This software uses enum to populate a dropdown list. So I therefore have an enum as shown below which display 'Yes' and 'No' in the dropdown.

 

   Public Enum myYesNo
       Yes
       No
   End Enum

 

This works fine, the problem / question I have is, am I able to dynamically build an enum using values from a datareader??

 

e.g. Not correct code just want to try and give an example

 

Public Enum myDynamic
 Do While myReader.Read
   ' Add a value from myReader to the Enum
 Loop
End Enum

 

As I said I have not come across Enum before and I have read the posts on this forum about Enum, but none of them cover anything like this, maybe because it is not possible???

 

Anyway thanks in advance

 

Simon

Posted

Enum parameters are treated like constants. Therefore they are to be used during design-time, not run-time. You can do what you are asking to load values into a dropdown list, but not to load values into an Enum. You can use an Enum to fill a dropdown list, but only if that dropdown list remains constant after compilation.

 

Todd

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...