On Jan 1, 2013, at 11:27 AM, Carey Gagnon <[email protected]> wrote:

> I am trying to set a dTextBox BackColor dynamically based on the value of
> the field. Everything I have read in the mail archives etc, give example
> based on hand coded forms. All my forms are done in the ClassDesigner
> resulting in frmWhatever-code.py files.

        The Dynamic* properties are not exposed in the Class Designer; there 
are simply too many to add without making the surface cluttered.

        The general approach is to define them in the object's afterInit() 
method:

def afterInit(self):
        self.DynamicBackColor = someFunction

> My form has input controls, mainly dTextBoxes, that are filled with values
> after a search. If I could just figure out how to grab the value from the
> fieldI I'm sure I could figure out the rest.

        Usually 'self.Value' should work for a data-bound control. If you need 
any other value, you can call the bizobj's getFieldVal() method:

biz = self.Form.getBizobj("myDataSource")
testval = biz.getFieldVal("testfield")

> I'm just not sure where to
> start in the ClassDesigner when I want to "edit the code" for the one
> particular dTextBox.

        There are several ways; the easiest is to right-click on the control, 
and select 'Edit Code'. That will bring you to the code editor window, with the 
control you right clicked on selected as the object. Now just select the method 
you want from the method dropdown, or click 'New' to add a method to that 
object.

> I've tried onValueChanged, but that only fires if I type something in the
> field.
> I've tried onUpdate ...got nothing ...afterInit...same.
> 
> Can anybody point me in the right direction?

        If you define a DynamicBackColor property for a control, you don't have 
to then respond to events; the framework does that for you. Every time the data 
is updated, the function the returns the value is called to get the proper 
color for the current value, and the control's BackColor is then set to that.

        Read the section of the FAQ on the wiki for more info: 
http://wiki.dabodev.com/FAQs#DifferencePropertyAndDynamicProperty
( -or- http://j.mp/WiC45Y )



-- Ed Leafe

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to