?
Solved

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

Posted on 2003-12-11
3
Medium Priority
?
384 Views
Last Modified: 2010-04-16

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
Comment
Question by:nlwelch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Expert Comment

by:malharone
ID: 9930612
what's PropInfo
0
 

Author Comment

by:nlwelch
ID: 9930700
Sorry

System.Reflection.PropertyInfo
0
 
LVL 9

Accepted Solution

by:
malharone earned 1500 total points
ID: 9930823
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question