On Dec 20, 2007, at 8:59 AM, Dennis Meulensteen wrote:

> The line is:
> self.dPanel.dGrid.Columns[1].WordWrap = True
>
> I thought that, in order to reference the dGrid object, I had to  
> reference it
> via it's ancesters.
>
> Obviously this is not "quite" right....
>
> So I'll come right out and ask. How do I reference objects like  
> text boxes on
> a form correctly? I had hoped to discover this by myself but you  
> beat me to
> it.

        You can certainly reference objects through their containership  
hierarchy, using the dot-separated list of object names (i.e., the  
'Name' property). Assuming in this case that 'self' is the form, you  
have to look to make sure that there is an object that is a child of  
the form whose Name == "dPanel". If not, there's your problem (and  
that's what the error message indicates).

        As you can imagine, this method of grabbing references is very  
fragile and error-prone. What happens if you move an object? What  
happens if you rename one of the containers? Those actions, while  
perfectly reasonable things to do during design, will break the  
reference. So Dabo uses a way to create references that are unique  
across any given form. This is based on the "Registration" design  
pattern, in which objects that need to communicate with other objects  
"register" themselves with the form. There is a property named  
'RegID' that exists just for this: it is empty by default, but if you  
need to get refer to that object anywhere within the form, set the  
RegID to something unique and descriptive. When the form runs, the  
object will register itself with the form automatically, and after  
that you can then refer to it from anywhere using form-dot-RegID.  
Example: if you set your grid's RegID to be 'OrderGrid', the code to  
reference it would be 'self.OrderGrid' from within form methods, and  
'self.Form.OrderGrid' from any other object within the form. See  
http://dabodev.com/wiki/RegID for more info.

> For example what I have in my search method on the base Form is:
> self.Form.ddNaam.Value
> where ddNaam is a drop down list. I can reference it from self. but  
> that's
> about it. I have tried everything I can think of but I still don't  
> get it.

        In that line of code, 'ddNaam' must be the value of the dropdown's  
Name property, and it must be a direct child of the form for that  
code to work. The better solution would be to set its RegID to  
'ddNaam', and that would guarantee that your reference would work.

        RegID and Name are completely different properties; Name is required  
for all objects, and must be unique only among sibling controls.  
RegID is completely optional, and must be unique among all the  
controls on the form if it anything other than None.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com




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

Reply via email to