• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 394
  • Last Modified:

How to interpret the object returned from PropInfo.GetValue()


I'd like to save the results of the PropInfo.GetValue() to a file and use it later to recreate a form.  I'm having difficulties dealing with the variations of the object type returned by the method.  How does the PropertyGrid class enumerate the properties and determine the valid options?
 
 
0
nlwelch
Asked:
nlwelch
  • 2
1 Solution
 
malharoneCommented:
what's PropInfo
0
 
nlwelchAuthor Commented:
Sorry

System.Reflection.PropertyInfo
0
 
malharoneCommented:
this is general way for saving to file

    Public Sub readFromFile()
        Dim fs1 As New System.IO.FileStream("c:\file.txt", IO.FileMode.OpenOrCreate)
        Dim obj As Object
        Dim BinFormatter As New BinaryFormatter()
        obj = CType(BinFormatter.Deserialize(fs1), Object)
        '-- do obj.getType to get the object's type
        myPropInfo = obj
        fs1.Close()
    End Sub

    Public Sub writeToFile()
        Dim obj as Object
        Dim FS1 As New System.IO.FileStream("c:\file.txt", IO.FileMode.Create)
        Dim BinFormatter As New BinaryFormatter()
        BinFormatter.Serialize(FS1, myPropInfo.getValue(...))
        FS1.Close()
    End Sub


----

once you get the propInfo object, you can call propInfo.getValue(...).getType '<-- this will tell you the type of the object returned by the getValue method.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now