Is it possible to choose to run specific code at design time? What i would like to be able to do is to display a list of enums that are used ina specific form and menu. Is this possible to do? Any response would be appreciated. Thanks in advance!
+1
A:
Not sure exactly what you want, but in the Immediate Window (CTRL + ALT + I) you can type this type of command:
? System.Enum.GetNames(GetType(System.AttributeTargets))
...which will produce this output:
{Length=16}
(0): "Assembly"
(1): "Module"
(2): "Class"
(3): "Struct"
(4): "Enum"
(5): "Constructor"
(6): "Method"
(7): "Property"
(8): "Field"
(9): "Event"
(10): "Interface"
(11): "Parameter"
(12): "Delegate"
(13): "ReturnValue"
(14): "GenericParameter"
(15): "All"
Just replace System.AttributeTargets
with your favourite enum.
With a bit of creativity you can get all sorts of values from your code and also invoke methods in the same way (just quick examples here):
' print the value of a property '
? (New VBWindowsApplication1.Form1()).Text
' call some method '
? (New VBWindowsApplication1.Form1()).SomeMethod()
Of course there is a limit on how complex operations you can do here, but for simpler debugging purposes it works well.
Fredrik Mörk
2009-06-09 13:26:57
Wouldn't this only work at run time, not design time?
Macros
2009-06-09 13:38:16
@Macros; no, that's the point with the Immediate Window. Updated the answer with a link to the MSDN documentation.
Fredrik Mörk
2009-06-09 13:51:15