Solved

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

Posted on 2003-12-11
3
337 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
  • 2
3 Comments
 
LVL 9

Expert Comment

by:malharone
Comment Utility
what's PropInfo
0
 

Author Comment

by:nlwelch
Comment Utility
Sorry

System.Reflection.PropertyInfo
0
 
LVL 9

Accepted Solution

by:
malharone earned 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now