Page 1 of 1
Default Properties for a control
Posted: Fri Aug 07, 2009 2:19 pm
by ConvertFromOldNGs
by Torrie Moore >> Sun, 10 Oct 1999 20:11:49 GMT
I'm trying to set a default property for a control. I have used the windowCreated method to set the property but am finding that I cannot change the property value as the default is set every time the control is used. I tried the create method, but the value does not appear in painter. Can anyone help?
Torrie Moore
Concept Engineering
Re: Default Properties for a control
Posted: Fri Aug 07, 2009 2:19 pm
by ConvertFromOldNGs
by Joseph O'Dwyer >> Sun, 10 Oct 1999 20:57:31 GMT
Torrie,
You can use the isInPainter method of the control and only set the default values if this returns true in the windowCreated method.
Joseph O'Dwyer
BMIS
Re: Default Properties for a control
Posted: Fri Aug 07, 2009 2:19 pm
by ConvertFromOldNGs
by Craig Shearer >> Mon, 11 Oct 1999 20:37:49 GMT
Hi Torrie
You should use the create method to set default values for controls when they are painted in the Painter. I think the problem you were having is that you were perhaps adding a create method after you'd painted the control. The create method is only called once, which is when you first paint the control on the form.
You can set default values in the create method which can then be overridden by using the property sheet in the Painter.
Conversely, you could use the windowCreated method, but as you've discovered it gets called each time you open the form in the Painter and each time you show the form in your application. So, setting default values in the windowCreated method is only appropriate if you don't want to keep the settings overridden in the Painter, which I suspect is not what you want.
Another interesting point, you can set the default size of a control in the create method. So, you could have a standard size for buttons. Then, if you paint the control on the form by just dropping it on (ie. click the control button on the control palette, then single click on the form, rather than dragging a size) the default size will work. This is useful if you want to have a standard size for say button controls.
Craig.