Solved

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

Posted on 2003-12-11
3
369 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 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

749 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