Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
M

Mohamed Ali Jinnah

@Mohamed Ali Jinnah
About
Posts
4
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Web Part behaviour in Window Form
    M Mohamed Ali Jinnah

    Hi, Can we do the Web Part(ASP.NET) type functionality in Windows Form. If anybody having any idea or article, could you please share with me?

    Visual Basic csharp asp-net question

  • How to create a class inherited from StringConverter by Reflection.Emit (Dynamically)
    M Mohamed Ali Jinnah

    Hi all, Please can you help me on this. I want to create a class dynamically which is inherited from StringConverter with help of Reflection.Emit. Class --------------------------------- Public Class EngStatusConverter Inherits StringConverter Public Overloads Overrides Function GetStandardValuesSupported(ByVal context As ITypeDescriptorContext) As Boolean Return True End Function Public Overloads Overrides Function GetStandardValues(ByVal context As ITypeDescriptorContext) As StandardValuesCollection Return New StandardValuesCollection(New String() {"RUNNING", "IDLE"}) 'Return New StandardValuesCollection(sStdValues) End Function Public Overloads Overrides Function GetStandardValuesExclusive(ByVal context As ITypeDescriptorContext) As Boolean Return True End Function End Class Using Reflection.Emit ---------------------------- Dim oTypeBuilder As TypeBuilder = Nothing Dim oMethodBuilder As MethodBuilder = Nothing Dim oILGenerator As ILGenerator = Nothing Dim oConstructorInfo As ConstructorInfo = Nothing Dim oParams() As Type Try oTypeBuilder = foModuleBuilder.DefineType("EngStatusConverter", TypeAttributes.Class, GetType(StringConverter)) oMethodBuilder = oTypeBuilder.DefineMethod("GetStandardValuesSupported", MethodAttributes.Public, GetType(Boolean), New Type() {GetType(ITypeDescriptorContext)}) oILGenerator = oMethodBuilder.GetILGenerator oILGenerator.Emit(OpCodes.Ldarg_0, CType(True, Object)) oILGenerator.Emit(OpCodes.Ret) oMethodBuilder = oTypeBuilder.DefineMethod("GetStandardValues", MethodAttributes.Public, GetType(StandardValuesCollection), New Type() {GetType(ITypeDescriptorContext)}) oILGenerator = oMethodBuilder.GetILGenerator oParams = New Type() {GetType(String)} oConstructorInfo = GetType(StandardValuesCollection).GetConstructor(oParams) oILGenerator.Emit(OpCodes.Ldarg_0, oConstructorInfo) oILGenerator.Emit(OpCodes.Ret) oMethodBuilder = oTypeBuilder.DefineMethod("GetStandardValuesExclusive", MethodAttributes.Public, GetType(Boolean), New Type() {GetType(ITypeDescriptorContext)}) oILGenerator = oMethodBuilder.GetILGenerator oILGenerator.Emit(OpCodes.Ldarg_0

    Visual Basic help tutorial

  • How to Create typeconverter dynamically by reflection to use in a PropertyGrid?
    M Mohamed Ali Jinnah

    Hi, Thanks for your reply. I have to attach a TypeConverterAttribute to a property. Please see the following code. Property definition ------------------------------------ _ Public Property DefaultFileName() As String Get Return _defaultFileName End Get Set(ByVal Value As String) _defaultFileName = Value End Set End Property ------------------------------------ File Name Converter ------------------------------------ Public Class FileNameConverter Inherits StringConverter Public Overloads Overrides Function GetStandardValuesSupported( _ ByVal context As ITypeDescriptorContext) As Boolean Return True End Function Public Overloads Overrides Function GetStandardValues( _ ByVal context As ITypeDescriptorContext) _ As StandardValuesCollection Return New StandardValuesCollection(New String() {"New File", _ "File1", _ "Document1"}) End Function Public Overloads Overrides Function GetStandardValuesExclusive( _ ByVal context As ITypeDescriptorContext) As Boolean Return False End Function End Class My problem is, I have to create the FileNameConverter type dynamically with help of reflection. So I can return the dynamic values from GetStandardValues method. I need a way to create a type like filenameconverter thru reflection. Please give your suggesstion.

    Visual Basic help database tutorial question

  • How to Create typeconverter dynamically by reflection to use in a PropertyGrid?
    M Mohamed Ali Jinnah

    Hi, I am using the propertygrid control to get the application level parameters from the users. The object assigned to the propertygrid is created dynamically with help of reflection.emit. i achieved the functionalities of the propertygrid like Categories and Description of a property by using the SetCustomAttribute method of a property builder. I want to achieve the combo box functionality for a property (User can select a value from the combobox for the property). I know that we can achieve this by setting the TypeConverterAttribute for the property. My problem is, each property will have to show different values in the combo(Values are coming from a Database), so dynamically i have to create a TypeConverter which is inherited from StringConverter. This typeconverter should be assingned to the property by TypeConverterAttribute. My problem is how we have to create a TypeConverter which is inherited from StringConverter with help of Reflection.Emit. Please give you suggestions. Please find the code below. It is not working. I confused to write the reflection related codes. Please help me on this. Public Shared Function GetDynamicTypeConverted(ByRef foModuleBuilder As ModuleBuilder) As Type Dim oTypeBuilder As TypeBuilder = Nothing Dim oMethodBuilder As MethodBuilder = Nothing Dim oILGenerator As ILGenerator = Nothing Dim oConstructorInfo As ConstructorInfo = Nothing Dim oParams() As Type Try oTypeBuilder = foModuleBuilder.DefineType("EngStatusConverter", TypeAttributes.Class, GetType(StringConverter)) oMethodBuilder = oTypeBuilder.DefineMethod("GetStandardValuesSupported", MethodAttributes.Public, GetType(Boolean), New Type() {GetType(ITypeDescriptorContext)}) oILGenerator = oMethodBuilder.GetILGenerator oILGenerator.Emit(OpCodes.Ldarg_0, CType(True, Object)) oILGenerator.Emit(OpCodes.Ret) oMethodBuilder = oTypeBuilder.DefineMethod("GetStandardValues", MethodAttributes.Public, GetType(StandardValuesCollection), New Type() {GetType(ITypeDescriptorContext)}) oILGenerator = oMethodBuilder.GetILGenerator oParams = New Type() {GetType(String)} oConstructorInfo = GetType(StandardValuesCollection).GetConstructor(oParams) oILGenerator.Emit(OpCodes.Ldarg_0, oConstructorInfo) oILGenerator.Emit(OpCodes.Ret) oMet

    Visual Basic help database tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups