Click here to Skip to main content
15,914,820 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Using "Me." to reference an object Pin
Colin Angus Mackay13-Feb-07 4:22
Colin Angus Mackay13-Feb-07 4:22 
GeneralRe: Using "Me." to reference an object Pin
Dave Kreskowiak13-Feb-07 5:55
mveDave Kreskowiak13-Feb-07 5:55 
Questionpaint event problem? Pin
.NetRams13-Feb-07 1:06
.NetRams13-Feb-07 1:06 
AnswerRe: paint event problem? Pin
Dave Kreskowiak13-Feb-07 4:05
mveDave Kreskowiak13-Feb-07 4:05 
GeneralRe: paint event problem? Pin
.NetRams13-Feb-07 19:17
.NetRams13-Feb-07 19:17 
GeneralRe: paint event problem? Pin
Dave Kreskowiak15-Feb-07 4:19
mveDave Kreskowiak15-Feb-07 4:19 
AnswerRe: paint event problem? Pin
Navneet Hegde14-Feb-07 2:54
Navneet Hegde14-Feb-07 2:54 
QuestionCreating enum at runtime and showing it on a property grid Pin
THEMYTH12-Feb-07 23:30
THEMYTH12-Feb-07 23:30 
Hi coders,

I am planning to create an enum at runtime and set it as a property of a class.

That is,
Class MyClass
   Public Property Type As (New Created Enum)
   ....
End Class

For creating an enum at runtime I have used the following code
     Public Function CreateEnum() As [Enum]
            Dim domain As AppDomain
            domain = Threading.Thread.GetDomain
            Dim name As New System.Reflection.AssemblyName
            name.Name = "EnumCounters"
            Dim asmBuilder As System.Reflection.emit.AssemblyBuilder
            asmBuilder = domain.DefineDynamicAssembly(name, Reflection.Emit.AssemblyBuilderAccess.Run)
            Dim modBuilder As ModuleBuilder
            modBuilder = asmBuilder.DefineDynamicModule("EnumModule")
            Dim enumBuilder As EnumBuilder
            enumBuilder = modBuilder.DefineEnum("EnumCounters", TypeAttributes.Public, GetType(Integer))


'----- HERE IS WHERE I ADD THE ITEMS
            For i As Integer = 0 To DiagManager.Counters.Count - 1
                enumBuilder.DefineLiteral(CType(DiagManager.Counters(i), Counter).Caption, i)
            Next
'-----
            Dim enumType As Type = enumBuilder.CreateType
            Dim enumObj As [Enum] = System.Activator.CreateInstance(enumType)

            Return enumObj
        End Function

Then, I set my property's value as the returned value of the function.
For full code please see (http://emreyazici.com/CodeFormatter.htm -- site does not have banners or advertisement. I only wrote the code)

Normally it would work. But when I assign the 'selectedobject' property of 'property grid' to the created instance of class, it does only display the FIRST item of enum in the property grid

http://emreyazici.com/res.jpg

But I want it to show all items

How may I correct it?

Thanks...






Best Regards
Emre YAZICI

AnswerRe: Creating enum at runtime and showing it on a property grid Pin
Dave Kreskowiak13-Feb-07 4:02
mveDave Kreskowiak13-Feb-07 4:02 
AnswerRe: Creating enum at runtime and showing it on a property grid Pin
TwoFaced13-Feb-07 9:20
TwoFaced13-Feb-07 9:20 
QuestionHow to programmatically set Admin privilege for exe (Vista) Pin
sp_ranjan12-Feb-07 22:42
sp_ranjan12-Feb-07 22:42 
AnswerRe: How to programmatically set Admin privilege for exe (Vista) Pin
Colin Angus Mackay13-Feb-07 1:46
Colin Angus Mackay13-Feb-07 1:46 
GeneralRe: How to programmatically set Admin privilege for exe (Vista) Pin
sp_ranjan13-Feb-07 2:25
sp_ranjan13-Feb-07 2:25 
GeneralRe: How to programmatically set Admin privilege for exe (Vista) Pin
Dave Kreskowiak13-Feb-07 2:37
mveDave Kreskowiak13-Feb-07 2:37 
GeneralRe: How to programmatically set Admin privilege for exe (Vista) Pin
sp_ranjan13-Feb-07 2:52
sp_ranjan13-Feb-07 2:52 
GeneralRe: How to programmatically set Admin privilege for exe (Vista) Pin
Dave Kreskowiak13-Feb-07 3:58
mveDave Kreskowiak13-Feb-07 3:58 
GeneralRe: How to programmatically set Admin privilege for exe (Vista) Pin
Colin Angus Mackay13-Feb-07 4:25
Colin Angus Mackay13-Feb-07 4:25 
Questioni need to show the result in COmmand prompt...but i am using Windows Application please help me Pin
pashitech12-Feb-07 19:45
pashitech12-Feb-07 19:45 
AnswerRe: i need to show the result in COmmand prompt...but i am using Windows Application please help me Pin
Christian Graus12-Feb-07 19:47
protectorChristian Graus12-Feb-07 19:47 
GeneralRe: i need to show the result in COmmand prompt...but i am using Windows Application please help me Pin
pashitech12-Feb-07 19:53
pashitech12-Feb-07 19:53 
GeneralRe: i need to show the result in COmmand prompt...but i am using Windows Application please help me Pin
M-Hall12-Feb-07 20:13
M-Hall12-Feb-07 20:13 
GeneralRe: i need to show the result in COmmand prompt...but i am using Windows Application please help me Pin
Christian Graus12-Feb-07 23:49
protectorChristian Graus12-Feb-07 23:49 
QuestionWrit Text File Pin
nawalage12-Feb-07 18:35
nawalage12-Feb-07 18:35 
AnswerRe: Writ Text File Pin
Christian Graus12-Feb-07 18:57
protectorChristian Graus12-Feb-07 18:57 
GeneralRe: Writ Text File Pin
nawalage12-Feb-07 19:37
nawalage12-Feb-07 19:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.