Property Grid

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?YW1pcg==?=

    Property Grid

    Is there a way to write all the items of a Property Grid to a file without
    having to list every item one by one to be written to the file?
  • Marc Gravell

    #2
    Re: Property Grid

    What format do you want the data? Would binary/xml serialization be an
    option? To mirror the way that PropertyGrid presents properties, you
    would need to ask the TypeConverter for the properties (normally
    TypeDescriptor. GetProperties is used, but not with PropertyGrid... ):

    foreach (PropertyDescri ptor prop in
    TypeDescriptor. GetConverter(ob j).GetPropertie s(obj))
    {
    object val = prop.GetValue(o bj);
    string s = prop.Converter. ConvertToString (val);
    // do something with s
    }

    (actually, to be thorough you would need to implement an
    ITypeDescriptor Context, but that might be overkill)

    Any use?

    Marc

    Comment

    • Rene

      #3
      Re: Property Grid

      Hi Mark,

      Since you are making use of controls that require a message pump (eg Form),
      I think you need to decorate the Main method with the [STA] attribute.. But
      then again, I may be full of it.



      [STA]

      static void Main()


      Comment

      • Rene

        #4
        Re: Property Grid

        mmmmm. actually, since you are not using Application.Run () then there is no
        message pump anyway right?.. never mind then... oooooops :)

        "Rene" <a@b.comwrote in message
        news:%23knL4hJr IHA.2520@TK2MSF TNGP02.phx.gbl. ..
        Hi Mark,
        >
        Since you are making use of controls that require a message pump (eg
        Form), I think you need to decorate the Main method with the [STA]
        attribute.. But then again, I may be full of it.
        >
        >
        >
        [STA]
        >
        static void Main()
        >
        >

        Comment

        • Marc Gravell

          #5
          Re: Property Grid

          mmmmm. actually, since you are not using Application.Run () then there is no
          message pump anyway right?.. never mind then... oooooops :)
          Exactly - Form was just chosen as something with more than a couple of
          properties, that would be instantly recognisable... it isn't actually
          used, so no STA required ;-p

          Marc

          Comment

          Working...