lidds Posted October 27, 2005 Posted October 27, 2005 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 Quote
tfowler Posted October 27, 2005 Posted October 27, 2005 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 Quote
lidds Posted October 27, 2005 Author Posted October 27, 2005 Thanks tfowler, I thought that would be the case. Cheers Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.