>>Arrrgh. Is this what you need to do to add a property at runtime? Couldn't you just type:
>>
>>
MyControl.AddProperty('MyNewProperty', 'MyDefaultValue')?
>>
>>Oh, wait, that's VFP syntax...
>
>This can easily be achieved by adding an item into a Dictionary or Hashtable in .NET. Of course, this could be of type object or a generic collection (giving type safety), and we could make the value a primitive type or a complex object or struct.
>
>Oh wait, that's .NET syntax :)
>
>On the other hand, you could argue that the desire to add a property at runtime is just totally bad design and/or a bad habit picked up by using a tool that lets you do bad things as a result of an "afterthought" (occasioned by bad design).
>
>I have seen a few threads on this board where VFP developers delving into .NET ask this or a similar variant of this question. I can tell you that it's only VFP developers who ask this question. The rest of the IT world seems to have managed without adding properties at runtime. Go figure :)
Well, yeah!
Adding properties on-the-fly certainly is a bad habit. But
should you want to do it and
should you not care about having properties as primitive types or what-not, a one-liner to set it up would certainly be a
nice thing to have. Of course, you
could build it into your own library and call it with a one-liner, I suppose, but if the development tool already had it in there, thought-out, implemented, tested and configured, that would be even nicer. And as for type safety, that argument could be and has been made back and forth ad nauseum, yet suffice it to say that the latest languages give you the choice (e.g., eTecnologia's VFP.NET compiler-under-development).
It's kind of like handing someone a rifle and telling them that if you have to shoot fast, leave the safety off, but be very, very careful! :-)
Pertti